Skip to content

Commit

Permalink
Update to latest apibuilder clients (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek committed May 10, 2018
1 parent 2c33fb7 commit 96e78a7
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 21 deletions.
14 changes: 14 additions & 0 deletions .apibuilder/.tracked_files
@@ -0,0 +1,14 @@
---
apicollective:
apibuilder-common:
ruby_client:
- src/apibuilder-cli/apicollective_apibuilder_common_v0_client.rb
apibuilder-api:
ruby_client:
- src/apibuilder-cli/apicollective_apibuilder_api_v0_client.rb
apibuilder-generator:
ruby_client:
- src/apibuilder-cli/apicollective_apibuilder_generator_v0_client.rb
apibuilder-spec:
ruby_client:
- src/apibuilder-cli/apicollective_apibuilder_spec_v0_client.rb
112 changes: 104 additions & 8 deletions src/apibuilder-cli/apicollective_apibuilder_api_v0_client.rb
@@ -1,6 +1,6 @@
# Generated by API Builder - https://www.apibuilder.io
# Service version: 0.14.12
# apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-api/0.14.12/ruby_client
# Service version: 0.14.13
# apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-api/0.14.13/ruby_client

require 'cgi'
require 'net/http'
Expand All @@ -26,8 +26,8 @@ module Constants

BASE_URL = 'https://api.apibuilder.io' unless defined?(Constants::BASE_URL)
NAMESPACE = 'io.apibuilder.api.v0' unless defined?(Constants::NAMESPACE)
USER_AGENT = 'apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-api/0.14.12/ruby_client' unless defined?(Constants::USER_AGENT)
VERSION = '0.14.12' unless defined?(Constants::VERSION)
USER_AGENT = 'apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-api/0.14.13/ruby_client' unless defined?(Constants::USER_AGENT)
VERSION = '0.14.13' unless defined?(Constants::VERSION)
VERSION_MAJOR = 0 unless defined?(VERSION_MAJOR)

end
Expand Down Expand Up @@ -194,7 +194,9 @@ def get(org_key, incoming={})
:key => (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String)),
:has_version => (x = opts.delete(:has_version); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('has_version', x)),
:limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
:offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer)
:offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
:sort_by => (x = opts.delete(:sort_by); x.nil? ? nil : (x = x; x.is_a?(::Io::Apibuilder::Api::V0::Models::AppSortBy) ? x : ::Io::Apibuilder::Api::V0::Models::AppSortBy.apply(x)).value),
:order => (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Apibuilder::Api::V0::Models::SortOrder) ? x : ::Io::Apibuilder::Api::V0::Models::SortOrder.apply(x)).value)
}.delete_if { |k, v| v.nil? }
r = @client.request("/#{CGI.escape(org_key)}").with_query(query).get
r.map { |x| ::Io::Apibuilder::Api::V0::Models::Application.new(x) }
Expand Down Expand Up @@ -1108,6 +1110,56 @@ def to_hash

end

class AppSortBy

attr_reader :value

def initialize(value)
@value = HttpClient::Preconditions.assert_class('value', value, String)
end

# Returns the instance of AppSortBy for this value, creating a new instance for an unknown value
def AppSortBy.apply(value)
if value.instance_of?(AppSortBy)
value
else
HttpClient::Preconditions.assert_class_or_nil('value', value, String)
value.nil? ? nil : (from_string(value) || AppSortBy.new(value))
end
end

# Returns the instance of AppSortBy for this value, or nil if not found
def AppSortBy.from_string(value)
HttpClient::Preconditions.assert_class('value', value, String)
AppSortBy.ALL.find { |v| v.value == value }
end

def AppSortBy.ALL
@@all ||= [AppSortBy.name, AppSortBy.created_at, AppSortBy.updated_at, AppSortBy.visibility]
end

def AppSortBy.name
@@_name ||= AppSortBy.new('name')
end

def AppSortBy.created_at
@@_created_at ||= AppSortBy.new('created_at')
end

def AppSortBy.updated_at
@@_updated_at ||= AppSortBy.new('updated_at')
end

def AppSortBy.visibility
@@_visibility ||= AppSortBy.new('visibility')
end

def to_hash
value
end

end

class OriginalType

attr_reader :value
Expand Down Expand Up @@ -1220,6 +1272,48 @@ def to_hash

end

class SortOrder

attr_reader :value

def initialize(value)
@value = HttpClient::Preconditions.assert_class('value', value, String)
end

# Returns the instance of SortOrder for this value, creating a new instance for an unknown value
def SortOrder.apply(value)
if value.instance_of?(SortOrder)
value
else
HttpClient::Preconditions.assert_class_or_nil('value', value, String)
value.nil? ? nil : (from_string(value) || SortOrder.new(value))
end
end

# Returns the instance of SortOrder for this value, or nil if not found
def SortOrder.from_string(value)
HttpClient::Preconditions.assert_class('value', value, String)
SortOrder.ALL.find { |v| v.value == value }
end

def SortOrder.ALL
@@all ||= [SortOrder.asc, SortOrder.desc]
end

def SortOrder.asc
@@_asc ||= SortOrder.new('asc')
end

def SortOrder.desc
@@_desc ||= SortOrder.new('desc')
end

def to_hash
value
end

end

class Visibility

attr_reader :value
Expand Down Expand Up @@ -1272,17 +1366,18 @@ def to_hash
# An application has a name and multiple versions of its API.
class Application

attr_reader :guid, :organization, :name, :key, :visibility, :description, :audit
attr_reader :guid, :organization, :name, :key, :visibility, :description, :last_updated_at, :audit

def initialize(incoming={})
opts = HttpClient::Helper.symbolize_keys(incoming)
HttpClient::Preconditions.require_keys(opts, [:guid, :organization, :name, :key, :visibility, :audit], 'Application')
HttpClient::Preconditions.require_keys(opts, [:guid, :organization, :name, :key, :visibility, :last_updated_at, :audit], 'Application')
@guid = HttpClient::Preconditions.assert_class('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String)
@organization = (x = opts.delete(:organization); x.is_a?(::Io::Apibuilder::Common::V0::Models::Reference) ? x : ::Io::Apibuilder::Common::V0::Models::Reference.new(x))
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
@key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
@visibility = (x = opts.delete(:visibility); x.is_a?(::Io::Apibuilder::Api::V0::Models::Visibility) ? x : ::Io::Apibuilder::Api::V0::Models::Visibility.apply(x))
@description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
@last_updated_at = HttpClient::Preconditions.assert_class('last_updated_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:last_updated_at)), DateTime)
@audit = (x = opts.delete(:audit); x.is_a?(::Io::Apibuilder::Common::V0::Models::Audit) ? x : ::Io::Apibuilder::Common::V0::Models::Audit.new(x))
end

Expand All @@ -1302,6 +1397,7 @@ def to_hash
:key => key,
:visibility => visibility.value,
:description => description,
:last_updated_at => last_updated_at,
:audit => audit.to_hash
}
end
Expand Down Expand Up @@ -3230,4 +3326,4 @@ def Helper.to_boolean(field_name, value)
end
end
end
end
end
Expand Up @@ -246,7 +246,7 @@ def execute(request)
end

def full_uri(path)
File.join(@base_uri.to_s, path)
path.start_with?(@base_uri.to_s) ? path : File.join(@base_uri.to_s, path)
end

# Called to configure SSL if the base uri requires it
Expand Down
Expand Up @@ -459,7 +459,7 @@ def execute(request)
end

def full_uri(path)
File.join(@base_uri.to_s, path)
path.start_with?(@base_uri.to_s) ? path : File.join(@base_uri.to_s, path)
end

# Called to configure SSL if the base uri requires it
Expand Down
65 changes: 54 additions & 11 deletions src/apibuilder-cli/apicollective_apibuilder_spec_v0_client.rb
@@ -1,6 +1,6 @@
# Generated by API Builder - https://www.apibuilder.io
# Service version: 0.14.12
# apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-spec/0.14.12/ruby_client
# Service version: 0.14.13
# apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-spec/0.14.13/ruby_client

require 'cgi'
require 'net/http'
Expand All @@ -24,8 +24,8 @@ class Client
module Constants

NAMESPACE = 'io.apibuilder.spec.v0' unless defined?(Constants::NAMESPACE)
USER_AGENT = 'apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-spec/0.14.12/ruby_client' unless defined?(Constants::USER_AGENT)
VERSION = '0.14.12' unless defined?(Constants::VERSION)
USER_AGENT = 'apibuilder 0.14.3 app.apibuilder.io/apicollective/apibuilder-spec/0.14.13/ruby_client' unless defined?(Constants::USER_AGENT)
VERSION = '0.14.13' unless defined?(Constants::VERSION)
VERSION_MAJOR = 0 unless defined?(VERSION_MAJOR)

end
Expand Down Expand Up @@ -291,6 +291,43 @@ def subtype_to_hash

end

# Used to indicate an API concern for a field that is specific to the field's
# usage but not necessarily its data type. For example, you might use
# annotations to mark that certain fields contain PII or PCI data and thus
# should not be stored once processing is complete. Annotations communicate
# meaning to consumers of an API and may also be used within an implementation
# or tooling; for example, using static analysis tools to detect logging of
# sensitive data.
class Annotation

attr_reader :name, :description, :deprecation

def initialize(incoming={})
opts = HttpClient::Helper.symbolize_keys(incoming)
HttpClient::Preconditions.require_keys(opts, [:name], 'Annotation')
@name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
@description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
@deprecation = (x = opts.delete(:deprecation); x.nil? ? nil : (x = x; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Deprecation) ? x : ::Io::Apibuilder::Spec::V0::Models::Deprecation.new(x)))
end

def to_json
JSON.dump(to_hash)
end

def copy(incoming={})
Annotation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

def to_hash
{
:name => name,
:description => description,
:deprecation => deprecation.nil? ? nil : deprecation.to_hash
}
end

end

class Apidoc

attr_reader :version
Expand Down Expand Up @@ -543,7 +580,7 @@ def to_hash

class Field

attr_reader :name, :type, :description, :deprecation, :default, :required, :minimum, :maximum, :example, :attributes
attr_reader :name, :type, :description, :deprecation, :default, :required, :minimum, :maximum, :example, :attributes, :annotations

def initialize(incoming={})
opts = HttpClient::Helper.symbolize_keys(incoming)
Expand All @@ -558,6 +595,7 @@ def initialize(incoming={})
@maximum = (x = opts.delete(:maximum); x.nil? ? nil : HttpClient::Preconditions.assert_class('maximum', x, Integer))
@example = (x = opts.delete(:example); x.nil? ? nil : HttpClient::Preconditions.assert_class('example', x, String))
@attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Attribute) ? x : ::Io::Apibuilder::Spec::V0::Models::Attribute.new(x)) }
@annotations = HttpClient::Preconditions.assert_class('annotations', (x = opts.delete(:annotations); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('annotations', v, String) }
end

def to_json
Expand All @@ -579,7 +617,8 @@ def to_hash
:minimum => minimum,
:maximum => maximum,
:example => example,
:attributes => attributes.map { |o| o.to_hash }
:attributes => attributes.map { |o| o.to_hash },
:annotations => annotations
}
end

Expand Down Expand Up @@ -628,7 +667,7 @@ def to_hash
# app.
class Import

attr_reader :uri, :namespace, :organization, :application, :version, :enums, :unions, :models
attr_reader :uri, :namespace, :organization, :application, :version, :enums, :unions, :models, :annotations

def initialize(incoming={})
opts = HttpClient::Helper.symbolize_keys(incoming)
Expand All @@ -641,6 +680,7 @@ def initialize(incoming={})
@enums = HttpClient::Preconditions.assert_class('enums', (x = opts.delete(:enums); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('enums', v, String) }
@unions = HttpClient::Preconditions.assert_class('unions', (x = opts.delete(:unions); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('unions', v, String) }
@models = HttpClient::Preconditions.assert_class('models', (x = opts.delete(:models); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('models', v, String) }
@annotations = HttpClient::Preconditions.assert_class('annotations', (x = opts.delete(:annotations); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Annotation) ? x : ::Io::Apibuilder::Spec::V0::Models::Annotation.new(x)) }
end

def to_json
Expand All @@ -660,7 +700,8 @@ def to_hash
:version => version,
:enums => enums,
:unions => unions,
:models => models
:models => models,
:annotations => annotations.map { |o| o.to_hash }
}
end

Expand Down Expand Up @@ -945,7 +986,7 @@ def to_hash

class Service

attr_reader :apidoc, :name, :organization, :application, :namespace, :version, :base_url, :description, :info, :headers, :imports, :enums, :unions, :models, :resources, :attributes
attr_reader :apidoc, :name, :organization, :application, :namespace, :version, :base_url, :description, :info, :headers, :imports, :enums, :unions, :models, :resources, :attributes, :annotations

def initialize(incoming={})
opts = HttpClient::Helper.symbolize_keys(incoming)
Expand All @@ -966,6 +1007,7 @@ def initialize(incoming={})
@models = HttpClient::Preconditions.assert_class('models', (x = opts.delete(:models); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Model) ? x : ::Io::Apibuilder::Spec::V0::Models::Model.new(x)) }
@resources = HttpClient::Preconditions.assert_class('resources', (x = opts.delete(:resources); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Resource) ? x : ::Io::Apibuilder::Spec::V0::Models::Resource.new(x)) }
@attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Attribute) ? x : ::Io::Apibuilder::Spec::V0::Models::Attribute.new(x)) }
@annotations = HttpClient::Preconditions.assert_class('annotations', (x = opts.delete(:annotations); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Apibuilder::Spec::V0::Models::Annotation) ? x : ::Io::Apibuilder::Spec::V0::Models::Annotation.new(x)) }
end

def to_json
Expand Down Expand Up @@ -993,7 +1035,8 @@ def to_hash
:unions => unions.map { |o| o.to_hash },
:models => models.map { |o| o.to_hash },
:resources => resources.map { |o| o.to_hash },
:attributes => attributes.map { |o| o.to_hash }
:attributes => attributes.map { |o| o.to_hash },
:annotations => annotations.map { |o| o.to_hash }
}
end

Expand Down Expand Up @@ -1166,7 +1209,7 @@ def execute(request)
end

def full_uri(path)
File.join(@base_uri.to_s, path)
path.start_with?(@base_uri.to_s) ? path : File.join(@base_uri.to_s, path)
end

# Called to configure SSL if the base uri requires it
Expand Down

0 comments on commit 96e78a7

Please sign in to comment.