Skip to content

Commit e4bd439

Browse files
Merge pull request #266 from HubSpot/feature/addNewApiClients
Add new api clients (Codegen Only)
2 parents b9c2886 + a9390cc commit e4bd439

245 files changed

Lines changed: 71714 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/hubspot/codegen/cms/pages/api/landing_pages_api.rb

Lines changed: 2754 additions & 0 deletions
Large diffs are not rendered by default.

lib/hubspot/codegen/cms/pages/api/site_pages_api.rb

Lines changed: 1896 additions & 0 deletions
Large diffs are not rendered by default.

lib/hubspot/codegen/cms/pages/api_client.rb

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
=begin
2+
#Pages
3+
4+
#Use these endpoints for interacting with Landing Pages and Site Pages
5+
6+
The version of the OpenAPI document: v3
7+
8+
Generated by: https://openapi-generator.tech
9+
OpenAPI Generator version: 6.2.1
10+
11+
=end
12+
13+
module Hubspot
14+
module Cms
15+
module Pages
16+
class ApiError < ::StandardError
17+
attr_reader :code, :response_headers, :response_body
18+
19+
# Usage examples:
20+
# ApiError.new
21+
# ApiError.new("message")
22+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
23+
# ApiError.new(:code => 404, :message => "Not Found")
24+
def initialize(arg = nil)
25+
if arg.is_a? Hash
26+
if arg.key?(:message) || arg.key?('message')
27+
super(arg[:message] || arg['message'])
28+
else
29+
super arg
30+
end
31+
32+
arg.each do |k, v|
33+
instance_variable_set "@#{k}", v
34+
end
35+
else
36+
super arg
37+
end
38+
end
39+
40+
# Override to_s to display a friendly error message
41+
def to_s
42+
message
43+
end
44+
45+
def message
46+
if @message.nil?
47+
msg = "Error message: the server returns an error"
48+
else
49+
msg = @message
50+
end
51+
52+
msg += "\nHTTP status code: #{code}" if code
53+
msg += "\nResponse headers: #{response_headers}" if response_headers
54+
msg += "\nResponse body: #{response_body}" if response_body
55+
56+
msg
57+
end
58+
end
59+
end
60+
end
61+
end
Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
=begin
2+
#Pages
3+
4+
#Use these endpoints for interacting with Landing Pages and Site Pages
5+
6+
The version of the OpenAPI document: v3
7+
8+
Generated by: https://openapi-generator.tech
9+
OpenAPI Generator version: 6.2.1
10+
11+
=end
12+
13+
module Hubspot
14+
module Cms
15+
module Pages
16+
class Configuration
17+
# Defines url scheme
18+
attr_accessor :scheme
19+
20+
# Defines url host
21+
attr_accessor :host
22+
23+
# Defines url base path
24+
attr_accessor :base_path
25+
26+
# Define server configuration index
27+
attr_accessor :server_index
28+
29+
# Define server operation configuration index
30+
attr_accessor :server_operation_index
31+
32+
# Default server variables
33+
attr_accessor :server_variables
34+
35+
# Default server operation variables
36+
attr_accessor :server_operation_variables
37+
38+
# Defines API keys used with API Key authentications.
39+
#
40+
# @return [Hash] key: parameter name, value: parameter value (API key)
41+
#
42+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
43+
# config.api_key['api_key'] = 'xxx'
44+
attr_accessor :api_key
45+
46+
# Defines API key prefixes used with API Key authentications.
47+
#
48+
# @return [Hash] key: parameter name, value: API key prefix
49+
#
50+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
51+
# config.api_key_prefix['api_key'] = 'Token'
52+
attr_accessor :api_key_prefix
53+
54+
# Defines the username used with HTTP basic authentication.
55+
#
56+
# @return [String]
57+
attr_accessor :username
58+
59+
# Defines the password used with HTTP basic authentication.
60+
#
61+
# @return [String]
62+
attr_accessor :password
63+
64+
# Defines the access token (Bearer) used with OAuth2.
65+
attr_accessor :access_token
66+
67+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
68+
# details will be logged with `logger.debug` (see the `logger` attribute).
69+
# Default to false.
70+
#
71+
# @return [true, false]
72+
attr_accessor :debugging
73+
74+
# Defines the logger used for debugging.
75+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
76+
#
77+
# @return [#debug]
78+
attr_accessor :logger
79+
80+
# Defines the temporary folder to store downloaded files
81+
# (for API endpoints that have file response).
82+
# Default to use `Tempfile`.
83+
#
84+
# @return [String]
85+
attr_accessor :temp_folder_path
86+
87+
# The time limit for HTTP request in seconds.
88+
# Default to 0 (never times out).
89+
attr_accessor :timeout
90+
91+
# Set this to false to skip client side validation in the operation.
92+
# Default to true.
93+
# @return [true, false]
94+
attr_accessor :client_side_validation
95+
96+
### TLS/SSL setting
97+
# Set this to false to skip verifying SSL certificate when calling API from https server.
98+
# Default to true.
99+
#
100+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
101+
#
102+
# @return [true, false]
103+
attr_accessor :verify_ssl
104+
105+
### TLS/SSL setting
106+
# Set this to false to skip verifying SSL host name
107+
# Default to true.
108+
#
109+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
110+
#
111+
# @return [true, false]
112+
attr_accessor :verify_ssl_host
113+
114+
### TLS/SSL setting
115+
# Set this to customize the certificate file to verify the peer.
116+
#
117+
# @return [String] the path to the certificate file
118+
#
119+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
120+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
121+
attr_accessor :ssl_ca_cert
122+
123+
### TLS/SSL setting
124+
# Client certificate file (for client certificate)
125+
attr_accessor :cert_file
126+
127+
### TLS/SSL setting
128+
# Client private key file (for client certificate)
129+
attr_accessor :key_file
130+
131+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
132+
# Default to nil.
133+
#
134+
# @see The params_encoding option of Ethon. Related source code:
135+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
136+
attr_accessor :params_encoding
137+
138+
139+
attr_accessor :inject_format
140+
141+
attr_accessor :force_ending_format
142+
143+
attr_accessor :error_handler
144+
145+
def initialize
146+
@scheme = 'https'
147+
@host = 'api.hubapi.com'
148+
@base_path = ''
149+
@server_index = 0
150+
@server_operation_index = {}
151+
@server_variables = {}
152+
@server_operation_variables = {}
153+
@api_key = {}
154+
@api_key_prefix = {}
155+
@client_side_validation = true
156+
@verify_ssl = true
157+
@verify_ssl_host = true
158+
@cert_file = nil
159+
@key_file = nil
160+
@timeout = 0
161+
@params_encoding = nil
162+
@debugging = false
163+
@inject_format = false
164+
@force_ending_format = false
165+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
166+
# error_handler params: { 'status_code': { max_retries: ..., seconds_delay: ... }, ... }
167+
@error_handler = {}
168+
169+
yield(self) if block_given?
170+
end
171+
172+
# The default Configuration object.
173+
def self.default
174+
@@default ||= Configuration.new
175+
end
176+
177+
def configure
178+
yield(self) if block_given?
179+
end
180+
181+
def scheme=(scheme)
182+
# remove :// from scheme
183+
@scheme = scheme.sub(/:\/\//, '')
184+
end
185+
186+
def host=(host)
187+
# remove http(s):// and anything after a slash
188+
@host = host.sub(/https?:\/\//, '').split('/').first
189+
end
190+
191+
def base_path=(base_path)
192+
# Add leading and trailing slashes to base_path
193+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
194+
@base_path = '' if @base_path == '/'
195+
end
196+
197+
# Returns base URL for specified operation based on server settings
198+
def base_url(operation = nil)
199+
index = server_operation_index.fetch(operation, server_index)
200+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
201+
202+
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
203+
end
204+
205+
# Gets API key (with prefix if set).
206+
# @param [String] param_name the parameter name of API key auth
207+
def api_key_with_prefix(param_name, param_alias = nil)
208+
key = @api_key[param_name]
209+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
210+
if @api_key_prefix[param_name]
211+
"#{@api_key_prefix[param_name]} #{key}"
212+
else
213+
key
214+
end
215+
end
216+
217+
# Gets Basic Auth token string
218+
def basic_auth_token
219+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
220+
end
221+
222+
# Returns Auth Settings hash for api client.
223+
def auth_settings
224+
{
225+
'oauth2' =>
226+
{
227+
type: 'oauth2',
228+
in: 'header',
229+
key: 'Authorization',
230+
value: "Bearer #{access_token}"
231+
},
232+
}
233+
end
234+
235+
# Returns an array of Server setting
236+
def server_settings
237+
[
238+
{
239+
url: "https://api.hubapi.com",
240+
description: "No description provided",
241+
}
242+
]
243+
end
244+
245+
def operation_server_settings
246+
{
247+
}
248+
end
249+
250+
# Returns URL based on server settings
251+
#
252+
# @param index array index of the server settings
253+
# @param variables hash of variable and the corresponding value
254+
def server_url(index, variables = {}, servers = nil)
255+
servers = server_settings if servers == nil
256+
257+
# check array index out of bound
258+
if (index < 0 || index >= servers.size)
259+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
260+
end
261+
262+
server = servers[index]
263+
url = server[:url]
264+
265+
return url unless server.key? :variables
266+
267+
# go through variable and assign a value
268+
server[:variables].each do |name, variable|
269+
if variables.key?(name)
270+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
271+
url.gsub! "{" + name.to_s + "}", variables[name]
272+
else
273+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
274+
end
275+
else
276+
# use default value
277+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
278+
end
279+
end
280+
281+
url
282+
end
283+
284+
end
285+
end
286+
end
287+
end

0 commit comments

Comments
 (0)