google-apis-generator 0.1.2 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/OVERVIEW.md +12 -9
- data/lib/google/apis/generator/templates/_class.tmpl +43 -0
- data/lib/google/apis/generator/templates/_method.tmpl +92 -0
- data/lib/google/apis/generator/templates/_representation.tmpl +51 -0
- data/lib/google/apis/generator/templates/_representation_stub.tmpl +17 -0
- data/lib/google/apis/generator/templates/_representation_type.tmpl +10 -0
- data/lib/google/apis/generator/templates/classes.rb.tmpl +29 -0
- data/lib/google/apis/generator/templates/dot-rspec.tmpl +2 -0
- data/lib/google/apis/generator/templates/dot-yardopts.tmpl +13 -0
- data/lib/google/apis/generator/templates/entry-point.rb.tmpl +15 -0
- data/lib/google/apis/generator/templates/gemfile.tmpl +23 -0
- data/lib/google/apis/generator/templates/gemspec.tmpl +33 -0
- data/lib/google/apis/generator/templates/generated_spec.rb.tmpl +27 -0
- data/lib/google/apis/generator/templates/initial-changelog.md.tmpl +2 -0
- data/lib/google/apis/generator/templates/initial-gem_version.rb.tmpl +28 -0
- data/lib/google/apis/generator/templates/license.md.tmpl +202 -0
- data/lib/google/apis/generator/templates/module.rb.tmpl +42 -0
- data/lib/google/apis/generator/templates/overview.md.tmpl +96 -0
- data/lib/google/apis/generator/templates/rakefile.tmpl +28 -0
- data/lib/google/apis/generator/templates/repo-metadata.json.tmpl +7 -0
- data/lib/google/apis/generator/templates/representations.rb.tmpl +32 -0
- data/lib/google/apis/generator/templates/service.rb.tmpl +63 -0
- data/lib/google/apis/generator/version.rb +1 -1
- data/lib/google/apis/generator.rb +1 -0
- metadata +40 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8223f043b3a3d587c76c4c1a86462691265f14cf5ce034afddfa477e925c300c
|
4
|
+
data.tar.gz: 4f1f114fdee4a0b769aaeb3743b5494902ed62fe92f33865e15569062fbb1156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93beb78657bf583d2f4acf21c6bb4b61417fa761ca9cceb6a459864d98bd0844f6ba57b701b200055c54be270bdad2f44d06cea5b6db2dbb3aadb40966f3a961
|
7
|
+
data.tar.gz: bd04ed9cf86d4f4e9890d2f8906a17be3ce3e8a629b11e6832439f8ebf672a121ca513b0ec6f894bf1cbc0420bb7a80fcde9f06b02650e87566ca098ac7f9c73
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### [0.4.1](https://www.github.com/googleapis/google-api-ruby-client/compare/google-apis-generator/v0.4.0...google-apis-generator/v0.4.1) (2022-01-11)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* **generator:** Fix field name in authorization example ([2ac44c2](https://www.github.com/googleapis/google-api-ruby-client/commit/2ac44c2145d111033cf344c624dad4c1d3188f25))
|
9
|
+
|
10
|
+
## 0.4.0 (2021-06-28)
|
11
|
+
|
12
|
+
* Update core dependency to require at least 0.4 and allow 1.x versions
|
13
|
+
|
14
|
+
## [0.3.0](https://www.github.com/googleapis/google-api-ruby-client/compare/google-apis-generator/v0.2.0...google-apis-generator/v0.3.0) (2021-06-01)
|
15
|
+
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
* Include repo-metadata.json in generated libraries ([91b0f2c](https://www.github.com/googleapis/google-api-ruby-client/commit/91b0f2c17d76fedf8aa3f7c905c424fe8b64a970))
|
20
|
+
|
21
|
+
## [0.2.0](https://www.github.com/googleapis/google-api-ruby-client/compare/google-apis-generator/v0.1.2...v0.2.0) (2021-03-07)
|
22
|
+
|
23
|
+
### Features
|
24
|
+
|
25
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0 ([d871146](https://www.github.com/googleapis/google-api-ruby-client/commit/d871146916f3dd19a12820c03068b3861a4bc879))
|
26
|
+
|
27
|
+
### Fixes
|
28
|
+
|
29
|
+
* Include templates in the gem distribution.
|
30
|
+
|
3
31
|
### [0.1.2](https://www.github.com/googleapis/google-api-ruby-client/compare/google-apis-generator/v0.1.1...v0.1.2) (2021-01-19)
|
4
32
|
|
5
33
|
|
data/OVERVIEW.md
CHANGED
@@ -1,17 +1,20 @@
|
|
1
|
-
#
|
1
|
+
# Generator for Google REST Clients
|
2
2
|
|
3
|
-
This library
|
4
|
-
|
5
|
-
|
3
|
+
This library implements the code generator used by legacy REST clients for
|
4
|
+
Google APIs. It automatically generates client gems given discovery documents.
|
5
|
+
Google-managed clients for publicly-available APIs are maintained using this
|
6
|
+
tool, and users may also use it to generate clients for private or early-access
|
7
|
+
APIs.
|
6
8
|
|
7
|
-
##
|
9
|
+
## Usage
|
8
10
|
|
9
|
-
|
11
|
+
To generate from a local discovery file:
|
10
12
|
|
11
|
-
|
12
|
-
* The [Auth Guide](https://github.com/googleapis/google-api-ruby-client/blob/master/docs/auth-guide.md) discusses authentication in the client libraries, including API keys, OAuth 2.0, service accounts, and environment variables.
|
13
|
+
$ generate-api gen <outdir> --file=<path>
|
13
14
|
|
14
|
-
|
15
|
+
A URL can also be specified:
|
16
|
+
|
17
|
+
$ generate-api gen <outdir> --url=<url>
|
15
18
|
|
16
19
|
## License
|
17
20
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<% if cls.type == 'object' || (cls.type == 'hash' && cls.properties.length > 0) -%>
|
2
|
+
|
3
|
+
# <%= block_comment(cls.description, 0, 1) %>
|
4
|
+
class <%= cls.generated_class_name %><% if cls.base_ref %> < <%= cls.base_ref.generated_type %><% end %>
|
5
|
+
include Google::Apis::Core::Hashable
|
6
|
+
<% for property in cls.properties.values -%>
|
7
|
+
|
8
|
+
# <%= block_comment(property.description, 2, 1) %>
|
9
|
+
# Corresponds to the JSON property `<%= property.name %>`
|
10
|
+
<% if property.format == 'byte' -%>
|
11
|
+
# NOTE: Values are automatically base64 encoded/decoded in the client library.
|
12
|
+
<% end -%>
|
13
|
+
# @return [<%= property.generated_type %>]
|
14
|
+
attr_accessor :<%= property.generated_name %>
|
15
|
+
<% if property.type == 'boolean' -%>
|
16
|
+
alias_method :<%= property.generated_name %>?, :<%= property.generated_name %>
|
17
|
+
<% end -%>
|
18
|
+
<% end -%>
|
19
|
+
|
20
|
+
def initialize(**args)
|
21
|
+
<% if cls.discriminant -%>
|
22
|
+
@<%= cls.properties[cls.discriminant].generated_name %> = '<%= cls.discriminant_value %>'
|
23
|
+
<% end -%>
|
24
|
+
update!(**args)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Update properties of this object
|
28
|
+
def update!(**args)
|
29
|
+
<% for property in cls.properties.values -%>
|
30
|
+
@<%= property.generated_name %> = args[:<%= property.generated_name %>] if args.key?(:<%= property.generated_name %>)
|
31
|
+
<% end -%>
|
32
|
+
end
|
33
|
+
<% for child_class in cls.properties.values -%>
|
34
|
+
<% if child_class._ref.nil? -%>
|
35
|
+
<%= indent(include('class', :cls => child_class, :api => api), 2) -%>
|
36
|
+
<% end -%>
|
37
|
+
<% end -%>
|
38
|
+
end
|
39
|
+
<% elsif cls.items && cls.items._ref.nil? -%>
|
40
|
+
<%= include('class', :cls => cls.items, :api => api) -%>
|
41
|
+
<% elsif cls.additional_properties && cls.additional_properties._ref.nil? -%>
|
42
|
+
<%= include('class', :cls => cls.additional_properties, :api => api) -%>
|
43
|
+
<% end -%>
|
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
# <%= block_comment(api_method.description, 0, 1) %>
|
3
|
+
<% for param in api_method.required_parameters -%>
|
4
|
+
# @param [<% if param.repeated? %>Array<<%= param.generated_type %>>, <% end %><%= param.generated_type %>] <%= param.generated_name %>
|
5
|
+
<% if param.description -%>
|
6
|
+
# <%= block_comment(param.description, 0, 3) %>
|
7
|
+
<% end -%>
|
8
|
+
<% end -%>
|
9
|
+
<% if api_method.request -%>
|
10
|
+
# @param [<%= api.schemas[api_method.request._ref].generated_type %>] <%= api.schemas[api_method.request._ref].generated_name %>_object
|
11
|
+
<% end -%>
|
12
|
+
<% for param in api_method.optional_query_parameters -%>
|
13
|
+
# @param [<% if param.repeated? %>Array<<%= param.generated_type %>>, <% end %><%= param.generated_type %>] <%= param.generated_name %>
|
14
|
+
<% if param.description -%>
|
15
|
+
# <%= block_comment(param.description, 0, 3) %>
|
16
|
+
<% end -%>
|
17
|
+
<% end -%>
|
18
|
+
<% for param in api.parameters.values.reject {|p| p.name == 'key'} -%>
|
19
|
+
# @param [<% if param.repeated? %>Array<<%= param.generated_type %>>, <% end %><%= param.generated_type %>] <%= param.generated_name %>
|
20
|
+
<% if param.description -%>
|
21
|
+
# <%= block_comment(param.description, 0, 3) %>
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
24
|
+
<% if api_method.supports_media_upload? -%>
|
25
|
+
# @param [IO, String] upload_source
|
26
|
+
# IO stream or filename containing content to upload
|
27
|
+
# @param [String] content_type
|
28
|
+
# Content type of the uploaded content.
|
29
|
+
<% elsif api_method.supports_media_download? -%>
|
30
|
+
# @param [IO, String] download_dest
|
31
|
+
# IO stream or filename to receive content download
|
32
|
+
<% end -%>
|
33
|
+
# @param [Google::Apis::RequestOptions] options
|
34
|
+
# Request-specific options
|
35
|
+
#
|
36
|
+
# @yield [result, err] Result & error if block supplied
|
37
|
+
<% if api_method.response -%>
|
38
|
+
# @yieldparam result [<%= api.schemas[api_method.response._ref].generated_type %>] parsed result object
|
39
|
+
# @yieldparam err [StandardError] error object if request failed
|
40
|
+
#
|
41
|
+
# @return [<%= api.schemas[api_method.response._ref].generated_type %>]
|
42
|
+
<% else -%>
|
43
|
+
# @yieldparam result [NilClass] No result returned for this method
|
44
|
+
# @yieldparam err [StandardError] error object if request failed
|
45
|
+
#
|
46
|
+
# @return [void]
|
47
|
+
<% end -%>
|
48
|
+
#
|
49
|
+
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
|
50
|
+
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
|
51
|
+
# @raise [Google::Apis::AuthorizationError] Authorization is required
|
52
|
+
def <%= api_method.generated_name %>(<% for param in api_method.required_parameters %><%= param.generated_name %>, <% end %><% if api_method.request %><%= api.schemas[api_method.request._ref].generated_name %>_object = nil, <% end %><% for param in api_method.optional_query_parameters %><%= param.generated_name %>: nil, <% end %><% for param in api.parameters.values.reject {|p| p.name == 'key'} %><%= param.generated_name %>: nil, <% end %><% if api_method.supports_media_upload? %>upload_source: nil, content_type: nil, <% elsif api_method.supports_media_download? %>download_dest: nil, <% end %>options: nil, &block)
|
53
|
+
<% if api_method.supports_media_upload? -%>
|
54
|
+
if upload_source.nil?
|
55
|
+
command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
56
|
+
else
|
57
|
+
command = make_upload_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
58
|
+
command.upload_source = upload_source
|
59
|
+
command.upload_content_type = content_type
|
60
|
+
end
|
61
|
+
<% elsif api_method.supports_media_download? -%>
|
62
|
+
if download_dest.nil?
|
63
|
+
command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
64
|
+
else
|
65
|
+
command = make_download_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
66
|
+
command.download_dest = download_dest
|
67
|
+
end
|
68
|
+
<% else -%>
|
69
|
+
command = make_simple_command(:<%= api_method.http_method.downcase %>, '<%= api_method.path %>', options)
|
70
|
+
<% end -%>
|
71
|
+
<% if api_method.request -%>
|
72
|
+
command.request_representation = <%= api.schemas[api_method.request._ref].generated_type %>::Representation
|
73
|
+
command.request_object = <%= api.schemas[api_method.request._ref].generated_name %>_object
|
74
|
+
<% end -%>
|
75
|
+
<% if api_method.response -%>
|
76
|
+
<% if api.force_alt_json? -%>
|
77
|
+
command.query['alt'] = 'json'
|
78
|
+
<% end -%>
|
79
|
+
command.response_representation = <%= api.schemas[api_method.response._ref].generated_type %>::Representation
|
80
|
+
command.response_class = <%= api.schemas[api_method.response._ref].generated_type %>
|
81
|
+
<% end -%>
|
82
|
+
<% for param in api_method.path_parameters -%>
|
83
|
+
command.params['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
84
|
+
<% end -%>
|
85
|
+
<% for param in api_method.query_parameters -%>
|
86
|
+
command.query['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
87
|
+
<% end -%>
|
88
|
+
<% for param in api.parameters.values.reject {|p| p.name == 'key'} -%>
|
89
|
+
command.query['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
90
|
+
<% end -%>
|
91
|
+
execute_or_queue_command(command, &block)
|
92
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<% if cls.type == 'object' -%>
|
2
|
+
|
3
|
+
class <%= cls.generated_class_name %>
|
4
|
+
# @private
|
5
|
+
class Representation < Google::Apis::Core::JsonRepresentation
|
6
|
+
<% if api.features && api.features.include?('dataWrapper') -%>
|
7
|
+
self.representation_wrap = lambda { |args| :data if args[:unwrap] == <%= cls.generated_type %> }
|
8
|
+
<% end -%>
|
9
|
+
<% if cls.variant -%>
|
10
|
+
def from_hash(hash, *args)
|
11
|
+
case hash['<%= cls.variant.discriminant %>']
|
12
|
+
<% for v in cls.variant.map -%>
|
13
|
+
<% ref = api.schemas[v._ref] %>
|
14
|
+
when '<%= v.type_value %>'
|
15
|
+
<%= ref.generated_type %>::Representation.new(<%= ref.generated_type %>.new).from_hash(hash, *args)
|
16
|
+
<% end -%>
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_hash(*args)
|
21
|
+
case represented
|
22
|
+
<% for v in cls.variant.map -%>
|
23
|
+
<% ref = api.schemas[v._ref] %>
|
24
|
+
when <%= ref.generated_type %>
|
25
|
+
<%= ref.generated_type %>::Representation.new(represented).to_hash(*args)
|
26
|
+
<% end -%>
|
27
|
+
end
|
28
|
+
end
|
29
|
+
<% else -%>
|
30
|
+
<% for property in cls.properties.values -%>
|
31
|
+
<% if property.type == 'hash' -%>
|
32
|
+
hash :<%= property.generated_name %>, as: '<%= property.name %>'<%= include('representation_type', :lead => ', ', :type => property.additional_properties, :api => api) %>
|
33
|
+
<% elsif property.type == 'array' -%>
|
34
|
+
collection :<%= property.generated_name %>, as: '<%= property.name %>'<%= include('representation_type', :lead => ', ', :type => property.items, :api => api) %>
|
35
|
+
<% else -%>
|
36
|
+
property :<%= property.generated_name %>,<% if ['uint64', 'int64'].include?(property.format) %> :numeric_string => true,<%end%><% if property.format == 'byte' %> :base64 => true,<%end%> as: '<%= property.name %>'<%= include('representation_type', :lead => ', ', :type => property, :api => api) %>
|
37
|
+
<% end -%>
|
38
|
+
<% end -%>
|
39
|
+
<% end -%>
|
40
|
+
end
|
41
|
+
<% for child_class in cls.properties.values -%>
|
42
|
+
<% if child_class._ref.nil? -%>
|
43
|
+
<%= indent(include('representation', :cls => child_class, :api => api), 2) -%>
|
44
|
+
<% end -%>
|
45
|
+
<% end -%>
|
46
|
+
end
|
47
|
+
<% elsif cls.items && cls.items._ref.nil? -%>
|
48
|
+
<%= include('representation', :cls => cls.items, :api => api) -%>
|
49
|
+
<% elsif cls.additional_properties && cls.additional_properties._ref.nil? -%>
|
50
|
+
<%= include('representation', :cls => cls.additional_properties, :api => api) -%>
|
51
|
+
<% end -%>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if cls.type == 'object' -%>
|
2
|
+
|
3
|
+
class <%= cls.generated_class_name %>
|
4
|
+
class Representation < Google::Apis::Core::JsonRepresentation; end
|
5
|
+
<% for child_class in cls.properties.values -%>
|
6
|
+
<% if child_class._ref.nil? -%>
|
7
|
+
<%= indent(include('representation_stub', :cls => child_class), 2) -%>
|
8
|
+
<% end -%>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
include Google::Apis::Core::JsonObjectSupport
|
12
|
+
end
|
13
|
+
<% elsif cls.items && cls.items._ref.nil? -%>
|
14
|
+
<%= include('representation_stub', :cls => cls.items, :api => api) -%>
|
15
|
+
<% elsif cls.additional_properties && cls.additional_properties._ref.nil? -%>
|
16
|
+
<%= include('representation_stub', :cls => cls.additional_properties, :api => api) -%>
|
17
|
+
<% end -%>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% if type.type == 'array' -%>
|
2
|
+
<%= lead %>:class => Array do
|
3
|
+
include Representable::JSON::Collection
|
4
|
+
items<%= include('representation_type', :lead => ' ' , :type => type.items, :api => api) %>
|
5
|
+
end
|
6
|
+
<% elsif ['date', 'date-time'].include?(type.format) -%>
|
7
|
+
<%= lead %>type: <%= type.generated_type %>
|
8
|
+
<% elsif type.type == 'object' -%>
|
9
|
+
<%= lead %>class: <%= type.generated_type %>, decorator: <%= type.generated_type %>::Representation
|
10
|
+
<% end -%>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'date'
|
16
|
+
require 'google/apis/core/base_service'
|
17
|
+
require 'google/apis/core/json_representation'
|
18
|
+
require 'google/apis/core/hashable'
|
19
|
+
require 'google/apis/errors'
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Apis
|
23
|
+
module <%= api.module_name %>
|
24
|
+
<% for cls in api.schemas.values.partition(&:variant).flatten -%>
|
25
|
+
<%= indent(include('class', :cls => cls, :api => api), 6) -%>
|
26
|
+
<% end -%>
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
--hide-void-return
|
2
|
+
--no-private
|
3
|
+
--verbose
|
4
|
+
--title=<%= api.gem_name %>
|
5
|
+
--markup-provider=redcarpet
|
6
|
+
--markup=markdown
|
7
|
+
--main OVERVIEW.md
|
8
|
+
lib/<%= api.base_path %>/*.rb
|
9
|
+
lib/<%= api.base_path %>.rb
|
10
|
+
-
|
11
|
+
OVERVIEW.md
|
12
|
+
CHANGELOG.md
|
13
|
+
LICENSE.md
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "<%= api.base_path %>"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem "bundler", ">= 1.17"
|
7
|
+
gem "rake", ">= 12.0"
|
8
|
+
gem "rspec", "~> 3.9"
|
9
|
+
gem "opencensus", "~> 0.5"
|
10
|
+
end
|
11
|
+
|
12
|
+
platforms :jruby do
|
13
|
+
group :development do
|
14
|
+
gem "jruby-openssl"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
platforms :ruby do
|
19
|
+
group :development do
|
20
|
+
gem "yard", "~> 0.9", ">= 0.9.25"
|
21
|
+
gem "redcarpet", "~> 3.5"
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path("lib/<%= api.base_path %>/gem_version", __dir__)
|
2
|
+
gem_version = <%= api.qualified_name %>::GEM_VERSION
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "<%= api.gem_name %>"
|
6
|
+
gem.version = gem_version
|
7
|
+
gem.authors = ["Google LLC"]
|
8
|
+
gem.email = "googleapis-packages@google.com"
|
9
|
+
gem.summary = "Simple REST client for <%= api.title %> <%= api.version %>"
|
10
|
+
gem.description =
|
11
|
+
"This is the simple REST client for <%= api.title %> <%= api.version %>." \
|
12
|
+
" Simple REST clients are Ruby client libraries that provide access to" \
|
13
|
+
" Google services via their HTTP REST API endpoints. These libraries are" \
|
14
|
+
" generated and updated automatically based on the discovery documents" \
|
15
|
+
" published by the service, and they handle most concerns such as" \
|
16
|
+
" authentication, pagination, retry, timeouts, and logging. You can use" \
|
17
|
+
" this client to access the <%= api.title %>, but note that some" \
|
18
|
+
" services may provide a separate modern client that is easier to use."
|
19
|
+
gem.homepage = "https://github.com/google/google-api-ruby-client"
|
20
|
+
gem.license = "Apache-2.0"
|
21
|
+
gem.metadata = {
|
22
|
+
"bug_tracker_uri" => "https://github.com/googleapis/google-api-ruby-client/issues",
|
23
|
+
"changelog_uri" => "https://github.com/googleapis/google-api-ruby-client/tree/main/generated/<%= api.gem_name %>/CHANGELOG.md",
|
24
|
+
"documentation_uri" => "https://googleapis.dev/ruby/<%= api.gem_name %>/v#{gem_version}",
|
25
|
+
"source_code_uri" => "https://github.com/googleapis/google-api-ruby-client/tree/main/generated/<%= api.gem_name %>"
|
26
|
+
}
|
27
|
+
|
28
|
+
gem.files = Dir.glob("lib/**/*.rb") + Dir.glob("*.md") + [".yardopts"]
|
29
|
+
gem.require_paths = ["lib"]
|
30
|
+
|
31
|
+
gem.required_ruby_version = '>= 2.5'
|
32
|
+
gem.add_runtime_dependency "google-apis-core", ">= 0.4", "< 2.a"
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "rspec"
|
16
|
+
|
17
|
+
RSpec.describe "<%= api.qualified_name %>" do
|
18
|
+
# Minimal test just to ensure no syntax errors in generated code
|
19
|
+
it "should load" do
|
20
|
+
expect do
|
21
|
+
require "<%= api.base_path %>"
|
22
|
+
end.not_to raise_error
|
23
|
+
expect do
|
24
|
+
<%= api.qualified_name %>::<%= api.service_name %>.new
|
25
|
+
end.not_to raise_error
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Apis
|
17
|
+
module <%= api.module_name %>
|
18
|
+
# Version of the <%= api.gem_name %> gem
|
19
|
+
GEM_VERSION = "0.0.0"
|
20
|
+
|
21
|
+
# Version of the code generator used to generate this client
|
22
|
+
GENERATOR_VERSION = "0.0.0"
|
23
|
+
|
24
|
+
# Revision of the discovery document this client was generated from
|
25
|
+
REVISION = "0"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require '<%= to_path(api.qualified_name) %>/service.rb'
|
16
|
+
require '<%= to_path(api.qualified_name) %>/classes.rb'
|
17
|
+
require '<%= to_path(api.qualified_name) %>/representations.rb'
|
18
|
+
require '<%= to_path(api.qualified_name) %>/gem_version.rb'
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Apis
|
22
|
+
# <%= api.title %>
|
23
|
+
#
|
24
|
+
# <%= block_comment(api.description, 4, 1) %>
|
25
|
+
#
|
26
|
+
<% if api.documentation_link -%>
|
27
|
+
# @see <%= api.documentation_link %>
|
28
|
+
<% end -%>
|
29
|
+
module <%= api.module_name %>
|
30
|
+
# Version of the <%= api.title %> this client connects to.
|
31
|
+
# This is NOT the gem version.
|
32
|
+
VERSION = '<%= api.version %>'
|
33
|
+
<% if api.auth && api.auth.oauth2 -%>
|
34
|
+
<% for scope_string, scope in api.auth.oauth2.scopes -%>
|
35
|
+
|
36
|
+
# <%= scope.description %>
|
37
|
+
<%= scope.constant %> = '<%= scope_string %>'
|
38
|
+
<% end -%>
|
39
|
+
<% end -%>
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# Simple REST client for version <%= api.version %> of the <%= api.title %>
|
2
|
+
|
3
|
+
This is a simple client library for version <%= api.version %> of the <%= api.title %>. It provides:
|
4
|
+
|
5
|
+
* A client object that connects to the HTTP/JSON REST endpoint for the service.
|
6
|
+
* Ruby objects for data structures related to the service.
|
7
|
+
* Integration with the googleauth gem for authentication using OAuth, API keys, and service accounts.
|
8
|
+
* Control of retry, pagination, and timeouts.
|
9
|
+
|
10
|
+
Note that although this client library is supported and will continue to be updated to track changes to the service, it is otherwise considered complete and not under active development. Many Google services, especially Google Cloud Platform services, may provide a more modern client that is under more active development and improvement. See the section below titled *Which client should I use?* for more information.
|
11
|
+
|
12
|
+
## Getting started
|
13
|
+
|
14
|
+
### Before you begin
|
15
|
+
|
16
|
+
There are a few setup steps you need to complete before you can use this library:
|
17
|
+
|
18
|
+
1. If you don't already have a Google account, [sign up](https://www.google.com/accounts).
|
19
|
+
2. If you have never created a Google APIs Console project, read about [Managing Projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects) and create a project in the [Google API Console](https://console.cloud.google.com/).
|
20
|
+
3. Most APIs need to be enabled for your project. [Enable it](https://console.cloud.google.com/apis/library/<%= api.name.downcase %>.googleapis.com) in the console.
|
21
|
+
|
22
|
+
### Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem '<%= api.gem_name %>', '~> 0.1'
|
28
|
+
```
|
29
|
+
|
30
|
+
And then execute:
|
31
|
+
|
32
|
+
```
|
33
|
+
$ bundle
|
34
|
+
```
|
35
|
+
|
36
|
+
Or install it yourself as:
|
37
|
+
|
38
|
+
```
|
39
|
+
$ gem install <%= api.gem_name %>
|
40
|
+
```
|
41
|
+
|
42
|
+
### Creating a client object
|
43
|
+
|
44
|
+
Once the gem is installed, you can load the client code and instantiate a client.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
# Load the client
|
48
|
+
require "<%= api.base_path %>"
|
49
|
+
|
50
|
+
# Create a client object
|
51
|
+
client = <%= api.qualified_name %>::<%= api.service_name %>.new
|
52
|
+
|
53
|
+
# Authenticate calls
|
54
|
+
client.authorization = # ... use the googleauth gem to create credentials
|
55
|
+
```
|
56
|
+
|
57
|
+
See the class reference docs for information on the methods you can call from a client.
|
58
|
+
|
59
|
+
## Documentation
|
60
|
+
|
61
|
+
More detailed descriptions of the Google simple REST clients are available in two documents.
|
62
|
+
|
63
|
+
* The [Usage Guide](https://github.com/googleapis/google-api-ruby-client/blob/main/docs/usage-guide.md) discusses how to make API calls, how to use the provided data structures, and how to work the various features of the client library, including media upload and download, error handling, retries, pagination, and logging.
|
64
|
+
* The [Auth Guide](https://github.com/googleapis/google-api-ruby-client/blob/main/docs/auth-guide.md) discusses authentication in the client libraries, including API keys, OAuth 2.0, service accounts, and environment variables.
|
65
|
+
|
66
|
+
(Note: the above documents are written for the simple REST clients in general, and their examples may not reflect the <%= api.name %> service in particular.)
|
67
|
+
|
68
|
+
For reference information on specific calls in the <%= api.title %>, see the {<%= api.qualified_name %>::<%= api.service_name %> class reference docs}.
|
69
|
+
|
70
|
+
## Which client should I use?
|
71
|
+
|
72
|
+
Google provides two types of Ruby API client libraries: **simple REST clients** and **modern clients**.
|
73
|
+
|
74
|
+
This library, `<%= api.gem_name %>`, is a simple REST client. You can identify these clients by their gem names, which are always in the form `google-apis-<servicename>_<serviceversion>`. The simple REST clients connect to HTTP/JSON REST endpoints and are automatically generated from service discovery documents. They support most API functionality, but their class interfaces are sometimes awkward.
|
75
|
+
|
76
|
+
Modern clients are produced by a modern code generator, sometimes combined with hand-crafted functionality. Most modern clients connect to high-performance gRPC endpoints, although a few are backed by REST services. Modern clients are available for many Google services, especially Google Cloud Platform services, but do not yet support all the services covered by the simple clients.
|
77
|
+
|
78
|
+
Gem names for modern clients are often of the form `google-cloud-<service_name>`. (For example, [google-cloud-pubsub](https://rubygems.org/gems/google-cloud-pubsub).) Note that most modern clients also have corresponding "versioned" gems with names like `google-cloud-<service_name>-<version>`. (For example, [google-cloud-pubsub-v1](https://rubygems.org/gems/google-cloud-pubsub-v1).) The "versioned" gems can be used directly, but often provide lower-level interfaces. In most cases, the main gem is recommended.
|
79
|
+
|
80
|
+
**For most users, we recommend the modern client, if one is available.** Compared with simple clients, modern clients are generally much easier to use and more Ruby-like, support more advanced features such as streaming and long-running operations, and often provide much better performance. You may consider using a simple client instead, if a modern client is not yet available for the service you want to use, or if you are not able to use gRPC on your infrastructure.
|
81
|
+
|
82
|
+
The [product documentation](<%= api.documentation_link %>) may provide guidance regarding the preferred client library to use.
|
83
|
+
|
84
|
+
## Supported Ruby versions
|
85
|
+
|
86
|
+
This library is supported on Ruby 2.5+.
|
87
|
+
|
88
|
+
Google provides official support for Ruby versions that are actively supported by Ruby Core -- that is, Ruby versions that are either in normal maintenance or in security maintenance, and not end of life. Currently, this means Ruby 2.5 and later. Older versions of Ruby _may_ still work, but are unsupported and not recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby support schedule.
|
89
|
+
|
90
|
+
## License
|
91
|
+
|
92
|
+
This library is licensed under Apache 2.0. Full license text is available in the {file:LICENSE.md LICENSE}.
|
93
|
+
|
94
|
+
## Support
|
95
|
+
|
96
|
+
Please [report bugs at the project on Github](https://github.com/google/google-api-ruby-client/issues). Don't hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-api-ruby-client) about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
task :release_gem do
|
3
|
+
Rake::Task["build"].invoke
|
4
|
+
Rake::Task["release:rubygem_push"].invoke
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rake/clean'
|
8
|
+
CLOBBER.include('coverage', 'doc')
|
9
|
+
CLEAN.include('.yardoc')
|
10
|
+
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'yard'
|
16
|
+
require 'yard/rake/yardoc_task'
|
17
|
+
YARD::Rake::YardocTask.new do |t|
|
18
|
+
t.files = ['lib/**/*.rb', 'generated/**/*.rb']
|
19
|
+
t.options = ['--verbose', '--markup', 'markdown']
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
task :yard
|
23
|
+
puts "YARD not available"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :ci => [:spec, :yard, :build]
|
27
|
+
|
28
|
+
task :default => :ci
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'date'
|
16
|
+
require 'google/apis/core/base_service'
|
17
|
+
require 'google/apis/core/json_representation'
|
18
|
+
require 'google/apis/core/hashable'
|
19
|
+
require 'google/apis/errors'
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Apis
|
23
|
+
module <%= api.module_name %>
|
24
|
+
<% for cls in api.schemas.values.partition(&:variant).flatten -%>
|
25
|
+
<%= indent(include('representation_stub', :cls => cls), 6) -%>
|
26
|
+
<% end -%>
|
27
|
+
<% for cls in api.schemas.values.partition(&:variant).flatten -%>
|
28
|
+
<%= indent(include('representation', :cls => cls, :api => api), 6) -%>
|
29
|
+
<% end -%>
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Copyright 2020 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'google/apis/core/base_service'
|
16
|
+
require 'google/apis/core/json_representation'
|
17
|
+
require 'google/apis/core/hashable'
|
18
|
+
require 'google/apis/errors'
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Apis
|
22
|
+
module <%= api.module_name %>
|
23
|
+
# <%= api.title %>
|
24
|
+
#
|
25
|
+
# <%= block_comment(api.description, 6, 2) %>
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# require '<%= to_path(api.qualified_name) %>'
|
29
|
+
#
|
30
|
+
# <%= api.name %> = <%= api.qualified_name %> # Alias the module
|
31
|
+
# service = <%= api.name %>::<%= api.service_name %>.new
|
32
|
+
#
|
33
|
+
<% if api.documentation_link -%>
|
34
|
+
# @see <%= api.documentation_link %>
|
35
|
+
<% end -%>
|
36
|
+
class <%= api.service_name %> < Google::Apis::Core::BaseService
|
37
|
+
<% for param in api.parameters.values.reject {|p| p.name == 'fields'} -%>
|
38
|
+
# @return [<%= param.generated_type %>]
|
39
|
+
# <%= block_comment(param.description, 8, 2) %>
|
40
|
+
attr_accessor :<%= param.generated_name %>
|
41
|
+
|
42
|
+
<% end -%>
|
43
|
+
def initialize
|
44
|
+
super('<%= api.root_url %>', '<%= api.service_path %>',
|
45
|
+
client_name: '<%= api.gem_name %>',
|
46
|
+
client_version: <%= api.qualified_name %>::GEM_VERSION)
|
47
|
+
@batch_path = '<%= api.batch_path %>'
|
48
|
+
end
|
49
|
+
<% for api_method in api.all_methods -%>
|
50
|
+
<%= indent(include('method', :api_method => api_method, :api => api), 8) -%>
|
51
|
+
<% end -%>
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def apply_command_defaults(command)
|
56
|
+
<% for param in api.parameters.values.reject {|p| p.name == 'fields'} -%>
|
57
|
+
command.query['<%= param.name %>'] = <%= param.generated_name %> unless <%= param.generated_name %>.nil?
|
58
|
+
<% end -%>
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -78,6 +78,7 @@ module Google
|
|
78
78
|
result.files[File.join(module_path, "service.rb")] = render_template("service.rb", context)
|
79
79
|
result.files[result.version_path] = render_template("initial-gem_version.rb", context)
|
80
80
|
result.files[File.join(spec_path, "generated_spec.rb")] = render_template("generated_spec.rb", context)
|
81
|
+
result.files[File.join(base_path, ".repo-metadata.json")] = render_template("repo-metadata.json", context)
|
81
82
|
result
|
82
83
|
end
|
83
84
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-apis-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -42,30 +42,36 @@ dependencies:
|
|
42
42
|
name: google-apis-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.4'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.a
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
57
|
+
version: '0.4'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.a
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: google-apis-discovery_v1
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
67
|
+
version: '0.5'
|
62
68
|
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
74
|
+
version: '0.5'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: thor
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +109,27 @@ files:
|
|
103
109
|
- lib/google/apis/generator/helpers.rb
|
104
110
|
- lib/google/apis/generator/model.rb
|
105
111
|
- lib/google/apis/generator/template.rb
|
112
|
+
- lib/google/apis/generator/templates/_class.tmpl
|
113
|
+
- lib/google/apis/generator/templates/_method.tmpl
|
114
|
+
- lib/google/apis/generator/templates/_representation.tmpl
|
115
|
+
- lib/google/apis/generator/templates/_representation_stub.tmpl
|
116
|
+
- lib/google/apis/generator/templates/_representation_type.tmpl
|
117
|
+
- lib/google/apis/generator/templates/classes.rb.tmpl
|
118
|
+
- lib/google/apis/generator/templates/dot-rspec.tmpl
|
119
|
+
- lib/google/apis/generator/templates/dot-yardopts.tmpl
|
120
|
+
- lib/google/apis/generator/templates/entry-point.rb.tmpl
|
121
|
+
- lib/google/apis/generator/templates/gemfile.tmpl
|
122
|
+
- lib/google/apis/generator/templates/gemspec.tmpl
|
123
|
+
- lib/google/apis/generator/templates/generated_spec.rb.tmpl
|
124
|
+
- lib/google/apis/generator/templates/initial-changelog.md.tmpl
|
125
|
+
- lib/google/apis/generator/templates/initial-gem_version.rb.tmpl
|
126
|
+
- lib/google/apis/generator/templates/license.md.tmpl
|
127
|
+
- lib/google/apis/generator/templates/module.rb.tmpl
|
128
|
+
- lib/google/apis/generator/templates/overview.md.tmpl
|
129
|
+
- lib/google/apis/generator/templates/rakefile.tmpl
|
130
|
+
- lib/google/apis/generator/templates/repo-metadata.json.tmpl
|
131
|
+
- lib/google/apis/generator/templates/representations.rb.tmpl
|
132
|
+
- lib/google/apis/generator/templates/service.rb.tmpl
|
106
133
|
- lib/google/apis/generator/updater.rb
|
107
134
|
- lib/google/apis/generator/version.rb
|
108
135
|
homepage: https://github.com/google/google-api-ruby-client
|
@@ -110,9 +137,9 @@ licenses:
|
|
110
137
|
- Apache-2.0
|
111
138
|
metadata:
|
112
139
|
bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
|
113
|
-
changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/
|
114
|
-
documentation_uri: https://googleapis.dev/ruby/google-apis-generator/v0.1
|
115
|
-
source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/
|
140
|
+
changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-generator/CHANGELOG.md
|
141
|
+
documentation_uri: https://googleapis.dev/ruby/google-apis-generator/v0.4.1
|
142
|
+
source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/main/google-apis-generator
|
116
143
|
post_install_message:
|
117
144
|
rdoc_options: []
|
118
145
|
require_paths:
|
@@ -121,14 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
148
|
requirements:
|
122
149
|
- - ">="
|
123
150
|
- !ruby/object:Gem::Version
|
124
|
-
version: '2.
|
151
|
+
version: '2.5'
|
125
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
153
|
requirements:
|
127
154
|
- - ">="
|
128
155
|
- !ruby/object:Gem::Version
|
129
156
|
version: '0'
|
130
157
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
158
|
+
rubygems_version: 3.3.4
|
132
159
|
signing_key:
|
133
160
|
specification_version: 4
|
134
161
|
summary: Code generator for legacy Google REST clients
|