google-cloud-automl 0.7.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +201 -0
  5. data/MIGRATING.md +324 -0
  6. data/README.md +97 -27
  7. data/lib/google-cloud-automl.rb +6 -2
  8. data/lib/google/cloud/automl.rb +132 -190
  9. data/lib/google/cloud/automl/version.rb +6 -2
  10. metadata +75 -111
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/automl/v1beta1.rb +0 -231
  13. data/lib/google/cloud/automl/v1beta1/annotation_payload_pb.rb +0 -34
  14. data/lib/google/cloud/automl/v1beta1/annotation_spec_pb.rb +0 -19
  15. data/lib/google/cloud/automl/v1beta1/automl_client.rb +0 -1909
  16. data/lib/google/cloud/automl/v1beta1/automl_client_config.json +0 -146
  17. data/lib/google/cloud/automl/v1beta1/automl_client_helpers.rb +0 -109
  18. data/lib/google/cloud/automl/v1beta1/classification_pb.rb +0 -66
  19. data/lib/google/cloud/automl/v1beta1/column_spec_pb.rb +0 -29
  20. data/lib/google/cloud/automl/v1beta1/credentials.rb +0 -41
  21. data/lib/google/cloud/automl/v1beta1/data_items_pb.rb +0 -88
  22. data/lib/google/cloud/automl/v1beta1/data_stats_pb.rb +0 -77
  23. data/lib/google/cloud/automl/v1beta1/data_types_pb.rb +0 -36
  24. data/lib/google/cloud/automl/v1beta1/dataset_pb.rb +0 -39
  25. data/lib/google/cloud/automl/v1beta1/detection_pb.rb +0 -52
  26. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/annotation_payload.rb +0 -63
  27. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/annotation_spec.rb +0 -39
  28. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/classification.rb +0 -212
  29. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/column_spec.rb +0 -67
  30. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_items.rb +0 -202
  31. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_stats.rb +0 -160
  32. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_types.rb +0 -99
  33. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/dataset.rb +0 -77
  34. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/detection.rb +0 -130
  35. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/geometry.rb +0 -43
  36. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/image.rb +0 -183
  37. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/io.rb +0 -1110
  38. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/model.rb +0 -88
  39. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/model_evaluation.rb +0 -96
  40. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/prediction_service.rb +0 -186
  41. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/ranges.rb +0 -31
  42. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/regression.rb +0 -41
  43. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/service.rb +0 -356
  44. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/table_spec.rb +0 -68
  45. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/tables.rb +0 -275
  46. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/temporal.rb +0 -33
  47. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text.rb +0 -54
  48. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_extraction.rb +0 -60
  49. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_segment.rb +0 -37
  50. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_sentiment.rb +0 -76
  51. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/translation.rb +0 -63
  52. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/video.rb +0 -35
  53. data/lib/google/cloud/automl/v1beta1/doc/google/longrunning/operations.rb +0 -51
  54. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/any.rb +0 -131
  55. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/duration.rb +0 -91
  56. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/field_mask.rb +0 -222
  57. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/struct.rb +0 -74
  58. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
  59. data/lib/google/cloud/automl/v1beta1/doc/google/rpc/status.rb +0 -39
  60. data/lib/google/cloud/automl/v1beta1/geometry_pb.rb +0 -21
  61. data/lib/google/cloud/automl/v1beta1/image_pb.rb +0 -50
  62. data/lib/google/cloud/automl/v1beta1/io_pb.rb +0 -80
  63. data/lib/google/cloud/automl/v1beta1/model_evaluation_pb.rb +0 -38
  64. data/lib/google/cloud/automl/v1beta1/model_pb.rb +0 -45
  65. data/lib/google/cloud/automl/v1beta1/operations_pb.rb +0 -90
  66. data/lib/google/cloud/automl/v1beta1/prediction_service_client.rb +0 -480
  67. data/lib/google/cloud/automl/v1beta1/prediction_service_client_config.json +0 -36
  68. data/lib/google/cloud/automl/v1beta1/prediction_service_pb.rb +0 -43
  69. data/lib/google/cloud/automl/v1beta1/prediction_service_services_pb.rb +0 -74
  70. data/lib/google/cloud/automl/v1beta1/ranges_pb.rb +0 -17
  71. data/lib/google/cloud/automl/v1beta1/regression_pb.rb +0 -20
  72. data/lib/google/cloud/automl/v1beta1/service_pb.rb +0 -180
  73. data/lib/google/cloud/automl/v1beta1/service_services_pb.rb +0 -158
  74. data/lib/google/cloud/automl/v1beta1/table_spec_pb.rb +0 -24
  75. data/lib/google/cloud/automl/v1beta1/tables_pb.rb +0 -58
  76. data/lib/google/cloud/automl/v1beta1/temporal_pb.rb +0 -18
  77. data/lib/google/cloud/automl/v1beta1/text_extraction_pb.rb +0 -32
  78. data/lib/google/cloud/automl/v1beta1/text_pb.rb +0 -34
  79. data/lib/google/cloud/automl/v1beta1/text_segment_pb.rb +0 -18
  80. data/lib/google/cloud/automl/v1beta1/text_sentiment_pb.rb +0 -29
  81. data/lib/google/cloud/automl/v1beta1/translation_pb.rb +0 -34
  82. data/lib/google/cloud/automl/v1beta1/video_pb.rb +0 -25
data/README.md CHANGED
@@ -1,42 +1,54 @@
1
- # Ruby Client for Cloud AutoML API
1
+ # Ruby Client for the Cloud AutoML API
2
2
 
3
- [Cloud AutoML API][Product Documentation]:
4
- Train high-quality custom machine learning models with minimum effort and
5
- machine learning expertise.
6
- - [Client Library Documentation][]
7
- - [Product Documentation][]
3
+ API Client library for the Cloud AutoML API
8
4
 
9
- ## Quick Start
10
- In order to use this library, you first need to go through the following
11
- steps:
5
+ AutoML makes the power of machine learning available to you even if you have limited knowledge of machine learning. You can use AutoML to build on Google's machine learning capabilities to create your own custom machine learning models that are tailored to your business needs, and then integrate those models into your applications and web sites.
12
6
 
13
- 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
14
- 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
15
- 3. [Enable the Cloud AutoML API.](https://console.cloud.google.com/apis/library/automl.googleapis.com)
16
- 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-automl/latest/file.AUTHENTICATION.html)
7
+ Actual client classes for the various versions of this API are defined in
8
+ _versioned_ client gems, with names of the form `google-cloud-automl-v*`.
9
+ The gem `google-cloud-automl` is the main client library that brings the
10
+ verisoned gems in as dependencies, and provides high-level methods for
11
+ constructing clients. More information on versioned clients can be found below
12
+ in the section titled *Which client should I use?*.
13
+
14
+ View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-automl/latest)
15
+ for this library, google-cloud-automl, to see the convenience methods for
16
+ constructing client objects. Reference documentation for the client objects
17
+ themselves can be found in the client library documentation for the versioned
18
+ client gems:
19
+ [google-cloud-automl-v1](https://googleapis.dev/ruby/google-cloud-automl-v1/latest),
20
+ [google-cloud-automl-v1beta1](https://googleapis.dev/ruby/google-cloud-automl-v1beta1/latest).
21
+
22
+ See also the [Product Documentation](https://cloud.google.com/automl)
23
+ for more usage information.
24
+
25
+ ## Quick Start
17
26
 
18
- ### Installation
19
27
  ```
20
28
  $ gem install google-cloud-automl
21
29
  ```
22
30
 
23
- ### Next Steps
24
- - Read the [Client Library Documentation][] for Cloud AutoML API
25
- to see other available methods on the client.
26
- - Read the [Cloud AutoML API Product documentation][Product Documentation]
27
- to learn more about the product and see How-to Guides.
28
- - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
29
- to see the full list of Cloud APIs that we cover.
31
+ In order to use this library, you first need to go through the following steps:
30
32
 
31
- [Client Library Documentation]: https://googleapis.dev/ruby/google-cloud-automl/latest
32
- [Product Documentation]: https://cloud.google.com/automl
33
+ 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
34
+ 1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
35
+ 1. [Enable the API.](https://console.cloud.google.com/apis/library/automl.googleapis.com)
36
+ 1. {file:AUTHENTICATION.md Set up authentication.}
37
+
38
+ ## Migrating from 0.x versions
39
+
40
+ The 1.0 release of the google-cloud-automl client is a significant upgrade
41
+ based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
42
+ and includes substantial interface changes. Existing code written for earlier
43
+ versions of this library will likely require updates to use this version.
44
+ See the {file:MIGRATING.md MIGRATING.md} document for more information.
33
45
 
34
46
  ## Enabling Logging
35
47
 
36
48
  To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
37
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
49
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
38
50
  or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
39
- that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
51
+ that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
40
52
  and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
41
53
 
42
54
  Configuring a Ruby stdlib logger:
@@ -59,11 +71,69 @@ end
59
71
 
60
72
  ## Supported Ruby Versions
61
73
 
62
- This library is supported on Ruby 2.4+.
74
+ This library is supported on Ruby 2.5+.
63
75
 
64
76
  Google provides official support for Ruby versions that are actively supported
65
77
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
66
- in security maintenance, and not end of life. Currently, this means Ruby 2.4
78
+ in security maintenance, and not end of life. Currently, this means Ruby 2.5
67
79
  and later. Older versions of Ruby _may_ still work, but are unsupported and not
68
80
  recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
69
81
  about the Ruby support schedule.
82
+
83
+ ## Which client should I use?
84
+
85
+ Most modern Ruby client libraries for Google APIs come in two flavors: the main
86
+ client library with a name such as `google-cloud-automl`,
87
+ and lower-level _versioned_ client libraries with names such as
88
+ `google-cloud-automl-v1`.
89
+ _In most cases, you should install the main client._
90
+
91
+ ### What's the difference between the main client and a versioned client?
92
+
93
+ A _versioned client_ provides a basic set of data types and client classes for
94
+ a _single version_ of a specific service. (That is, for a service with multiple
95
+ versions, there might be a separate versioned client for each service version.)
96
+ Most versioned clients are written and maintained by a code generator.
97
+
98
+ The _main client_ is designed to provide you with the _recommended_ client
99
+ interfaces for the service. There will be only one main client for any given
100
+ service, even a service with multiple versions. The main client includes
101
+ factory methods for constructing the client objects we recommend for most
102
+ users. In some cases, those will be classes provided by an underlying versioned
103
+ client; in other cases, they will be handwritten higher-level client objects
104
+ with additional capabilities, convenience methods, or best practices built in.
105
+ Generally, the main client will default to a recommended service version,
106
+ although in some cases you can override this if you need to talk to a specific
107
+ service version.
108
+
109
+ ### Why would I want to use the main client?
110
+
111
+ We recommend that most users install the main client gem for a service. You can
112
+ identify this gem as the one _without_ a version in its name, e.g.
113
+ `google-cloud-automl`.
114
+ The main client is recommended because it will embody the best practices for
115
+ accessing the service, and may also provide more convenient interfaces or
116
+ tighter integration into frameworks and third-party libraries. In addition, the
117
+ documentation and samples published by Google will generally demonstrate use of
118
+ the main client.
119
+
120
+ ### Why would I want to use a versioned client?
121
+
122
+ You can use a versioned client if you are content with a possibly lower-level
123
+ class interface, you explicitly want to avoid features provided by the main
124
+ client, or you want to access a specific service version not be covered by the
125
+ main client. You can identify versioned client gems because the service version
126
+ is part of the name, e.g. `google-cloud-automl-v1`.
127
+
128
+ ### What about the google-apis-<name> clients?
129
+
130
+ Client library gems with names that begin with `google-apis-` are based on an
131
+ older code generation technology. They talk to a REST/JSON backend (whereas
132
+ most modern clients talk to a [gRPC](https://grpc.io/) backend) and they may
133
+ not offer the same performance, features, and ease of use provided by more
134
+ modern clients.
135
+
136
+ The `google-apis-` clients have wide coverage across Google services, so you
137
+ might need to use one if there is no modern client available for the service.
138
+ However, if a modern client is available, we generally recommend it over the
139
+ older `google-apis-` clients.
@@ -1,4 +1,6 @@
1
- # Copyright 2019 Google LLC
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -12,4 +14,6 @@
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
16
 
15
- require "google/cloud/automl"
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/automl" unless defined? Google::Cloud::AutoML::VERSION
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2020 Google LLC
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,208 +14,148 @@
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
16
 
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ # Require this file early so that the version constant gets defined before
20
+ # requiring "google/cloud". This is because google-cloud-core will load the
21
+ # entrypoint (gem name) file, which in turn re-requires this file (hence
22
+ # causing a require cycle) unless the version constant is already defined.
23
+ require "google/cloud/automl/version"
15
24
 
16
- require "google/gax"
17
- require "pathname"
25
+ require "googleauth"
26
+ gem "google-cloud-core"
27
+ require "google/cloud" unless defined? ::Google::Cloud.new
28
+ require "google/cloud/config"
29
+
30
+ # Set the default configuration
31
+ ::Google::Cloud.configure.add_config! :automl do |config|
32
+ config.add_field! :endpoint, "automl.googleapis.com", match: ::String
33
+ config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
34
+ config.add_field! :scope, nil, match: [::Array, ::String]
35
+ config.add_field! :lib_name, nil, match: ::String
36
+ config.add_field! :lib_version, nil, match: ::String
37
+ config.add_field! :interceptors, nil, match: ::Array
38
+ config.add_field! :timeout, nil, match: ::Numeric
39
+ config.add_field! :metadata, nil, match: ::Hash
40
+ config.add_field! :retry_policy, nil, match: [::Hash, ::Proc]
41
+ config.add_field! :quota_project, nil, match: ::String
42
+ end
18
43
 
19
44
  module Google
20
45
  module Cloud
21
- # rubocop:disable LineLength
22
-
23
- ##
24
- # # Ruby Client for Cloud AutoML API
25
- #
26
- # [Cloud AutoML API][Product Documentation]:
27
- # Train high-quality custom machine learning models with minimum effort and
28
- # machine learning expertise.
29
- # - [Product Documentation][]
30
- #
31
- # ## Quick Start
32
- # In order to use this library, you first need to go through the following
33
- # steps:
34
- #
35
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
- # 3. [Enable the Cloud AutoML API.](https://console.cloud.google.com/apis/library/automl.googleapis.com)
38
- # 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-automl/latest/file.AUTHENTICATION.html)
39
- #
40
- # ### Installation
41
- # ```
42
- # $ gem install google-cloud-automl
43
- # ```
44
- #
45
- # ### Next Steps
46
- # - Read the [Cloud AutoML API Product documentation][Product Documentation]
47
- # to learn more about the product and see How-to Guides.
48
- # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
49
- # to see the full list of Cloud APIs that we cover.
50
- #
51
- # [Product Documentation]: https://cloud.google.com/automl
52
- #
53
- # ## Enabling Logging
54
- #
55
- # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
56
- # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
57
- # or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
58
- # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
59
- # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
60
- #
61
- # Configuring a Ruby stdlib logger:
62
- #
63
- # ```ruby
64
- # require "logger"
65
- #
66
- # module MyLogger
67
- # LOGGER = Logger.new $stderr, level: Logger::WARN
68
- # def logger
69
- # LOGGER
70
- # end
71
- # end
72
- #
73
- # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
74
- # module GRPC
75
- # extend MyLogger
76
- # end
77
- # ```
78
- #
79
46
  module AutoML
80
- # rubocop:enable LineLength
81
-
82
- FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("automl"))
47
+ ##
48
+ # Create a new client object for PredictionService.
49
+ #
50
+ # By default, this returns an instance of
51
+ # [Google::Cloud::AutoML::V1::PredictionService::Client](https://googleapis.dev/ruby/google-cloud-automl-v1/latest/Google/Cloud/AutoML/V1/PredictionService/Client.html)
52
+ # for version V1 of the API.
53
+ # However, you can specify specify a different API version by passing it in the
54
+ # `version` parameter. If the PredictionService service is
55
+ # supported by that API version, and the corresponding gem is available, the
56
+ # appropriate versioned client will be returned.
57
+ #
58
+ # ## About PredictionService
59
+ #
60
+ # AutoML Prediction API.
61
+ #
62
+ # On any input that is documented to expect a string parameter in
63
+ # snake_case or kebab-case, either of those cases is accepted.
64
+ #
65
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
66
+ # Defaults to `:v1`.
67
+ # @return [PredictionService::Client] A client object for the specified version.
68
+ #
69
+ def self.prediction_service version: :v1, &block
70
+ require "google/cloud/automl/#{version.to_s.downcase}"
83
71
 
84
- AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
85
- .select { |file| File.directory?(file) }
86
- .select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
87
- .select { |dir| File.exist?(dir + ".rb") }
88
- .map { |dir| File.basename(dir) }
72
+ package_name = Google::Cloud::AutoML
73
+ .constants
74
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
75
+ .first
76
+ package_module = Google::Cloud::AutoML.const_get package_name
77
+ package_module.const_get(:PredictionService).const_get(:Client).new(&block)
78
+ end
89
79
 
90
- module AutoML
91
- ##
92
- # AutoML Server API.
93
- #
94
- # The resource names are assigned by the server.
95
- # The server never reuses names that it has created after the resources with
96
- # those names are deleted.
97
- #
98
- # An ID of a resource is the last element of the item's resource name. For
99
- # `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`, then
100
- # the id for the item is `{dataset_id}`.
101
- #
102
- # Currently the only supported `location_id` is "us-central1".
103
- #
104
- # On any input that is documented to expect a string parameter in
105
- # snake_case or kebab-case, either of those cases is accepted.
106
- #
107
- # @param version [Symbol, String]
108
- # The major version of the service to be used. By default :v1beta1
109
- # is used.
110
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
111
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
112
- # Provides the means for authenticating requests made by the client. This parameter can
113
- # be many types.
114
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
115
- # authenticating requests made by this client.
116
- # A `String` will be treated as the path to the keyfile to be used for the construction of
117
- # credentials for this client.
118
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
119
- # credentials for this client.
120
- # A `GRPC::Core::Channel` will be used to make calls through.
121
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
122
- # should already be composed with a `GRPC::Core::CallCredentials` object.
123
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
124
- # metadata for requests, generally, to give OAuth credentials.
125
- # @param scopes [Array<String>]
126
- # The OAuth scopes for this service. This parameter is ignored if
127
- # an updater_proc is supplied.
128
- # @param client_config [Hash]
129
- # A Hash for call options for each method. See
130
- # Google::Gax#construct_settings for the structure of
131
- # this data. Falls back to the default config if not specified
132
- # or the specified config is missing data points.
133
- # @param timeout [Numeric]
134
- # The default timeout, in seconds, for calls made through this client.
135
- # @param metadata [Hash]
136
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
137
- # @param service_address [String]
138
- # Override for the service hostname, or `nil` to leave as the default.
139
- # @param service_port [Integer]
140
- # Override for the service port, or `nil` to leave as the default.
141
- # @param exception_transformer [Proc]
142
- # An optional proc that intercepts any exceptions raised during an API call to inject
143
- # custom error handling.
144
- def self.new(*args, version: :v1beta1, **kwargs)
145
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
146
- raise "The version: #{version} is not available. The available versions " \
147
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
148
- end
80
+ ##
81
+ # Create a new client object for AutoML.
82
+ #
83
+ # By default, this returns an instance of
84
+ # [Google::Cloud::AutoML::V1::AutoML::Client](https://googleapis.dev/ruby/google-cloud-automl-v1/latest/Google/Cloud/AutoML/V1/AutoML/Client.html)
85
+ # for version V1 of the API.
86
+ # However, you can specify specify a different API version by passing it in the
87
+ # `version` parameter. If the AutoML service is
88
+ # supported by that API version, and the corresponding gem is available, the
89
+ # appropriate versioned client will be returned.
90
+ #
91
+ # ## About AutoML
92
+ #
93
+ # AutoML Server API.
94
+ #
95
+ # The resource names are assigned by the server.
96
+ # The server never reuses names that it has created after the resources with
97
+ # those names are deleted.
98
+ #
99
+ # An ID of a resource is the last element of the item's resource name. For
100
+ # `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`, then
101
+ # the id for the item is `{dataset_id}`.
102
+ #
103
+ # Currently the only supported `location_id` is "us-central1".
104
+ #
105
+ # On any input that is documented to expect a string parameter in
106
+ # snake_case or kebab-case, either of those cases is accepted.
107
+ #
108
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
109
+ # Defaults to `:v1`.
110
+ # @return [AutoML::Client] A client object for the specified version.
111
+ #
112
+ def self.auto_ml version: :v1, &block
113
+ require "google/cloud/automl/#{version.to_s.downcase}"
149
114
 
150
- require "#{FILE_DIR}/#{version.to_s.downcase}"
151
- version_module = Google::Cloud::AutoML
152
- .constants
153
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
154
- .first
155
- Google::Cloud::AutoML.const_get(version_module)::AutoML.new(*args, **kwargs)
156
- end
115
+ package_name = Google::Cloud::AutoML
116
+ .constants
117
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
118
+ .first
119
+ package_module = Google::Cloud::AutoML.const_get package_name
120
+ package_module.const_get(:AutoML).const_get(:Client).new(&block)
157
121
  end
158
122
 
159
- module Prediction
160
- ##
161
- # AutoML Prediction API.
162
- #
163
- # On any input that is documented to expect a string parameter in
164
- # snake_case or kebab-case, either of those cases is accepted.
165
- #
166
- # @param version [Symbol, String]
167
- # The major version of the service to be used. By default :v1beta1
168
- # is used.
169
- # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
170
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
171
- # Provides the means for authenticating requests made by the client. This parameter can
172
- # be many types.
173
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
174
- # authenticating requests made by this client.
175
- # A `String` will be treated as the path to the keyfile to be used for the construction of
176
- # credentials for this client.
177
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
178
- # credentials for this client.
179
- # A `GRPC::Core::Channel` will be used to make calls through.
180
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
181
- # should already be composed with a `GRPC::Core::CallCredentials` object.
182
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
183
- # metadata for requests, generally, to give OAuth credentials.
184
- # @param scopes [Array<String>]
185
- # The OAuth scopes for this service. This parameter is ignored if
186
- # an updater_proc is supplied.
187
- # @param client_config [Hash]
188
- # A Hash for call options for each method. See
189
- # Google::Gax#construct_settings for the structure of
190
- # this data. Falls back to the default config if not specified
191
- # or the specified config is missing data points.
192
- # @param timeout [Numeric]
193
- # The default timeout, in seconds, for calls made through this client.
194
- # @param metadata [Hash]
195
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
196
- # @param service_address [String]
197
- # Override for the service hostname, or `nil` to leave as the default.
198
- # @param service_port [Integer]
199
- # Override for the service port, or `nil` to leave as the default.
200
- # @param exception_transformer [Proc]
201
- # An optional proc that intercepts any exceptions raised during an API call to inject
202
- # custom error handling.
203
- def self.new(*args, version: :v1beta1, **kwargs)
204
- unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
205
- raise "The version: #{version} is not available. The available versions " \
206
- "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
207
- end
123
+ ##
124
+ # Configure the google-cloud-automl library.
125
+ #
126
+ # The following configuration parameters are supported:
127
+ #
128
+ # * `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) -
129
+ # The path to the keyfile as a String, the contents of the keyfile as a
130
+ # Hash, or a Google::Auth::Credentials object.
131
+ # * `lib_name` (*type:* `String`) -
132
+ # The library name as recorded in instrumentation and logging.
133
+ # * `lib_version` (*type:* `String`) -
134
+ # The library version as recorded in instrumentation and logging.
135
+ # * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
136
+ # An array of interceptors that are run before calls are executed.
137
+ # * `timeout` (*type:* `Numeric`) -
138
+ # Default timeout in seconds.
139
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) -
140
+ # Additional gRPC headers to be sent with the call.
141
+ # * `retry_policy` (*type:* `Hash`) -
142
+ # The retry policy. The value is a hash with the following keys:
143
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
144
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
145
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
146
+ # * `:retry_codes` (*type:* `Array<String>`) -
147
+ # The error codes that should trigger a retry.
148
+ #
149
+ # @return [::Google::Cloud::Config] The default configuration used by this library
150
+ #
151
+ def self.configure
152
+ yield ::Google::Cloud.configure.automl if block_given?
208
153
 
209
- require "#{FILE_DIR}/#{version.to_s.downcase}"
210
- version_module = Google::Cloud::AutoML
211
- .constants
212
- .select {|sym| sym.to_s.downcase == version.to_s.downcase}
213
- .first
214
- Google::Cloud::AutoML.const_get(version_module)::Prediction.new(*args, **kwargs)
215
- end
154
+ ::Google::Cloud.configure.automl
216
155
  end
217
156
  end
218
157
  end
219
158
  end
159
+
160
+ helper_path = ::File.join __dir__, "automl", "helpers.rb"
161
+ require "google/cloud/automl/helpers" if ::File.file? helper_path