From 0d6752e407ca7cc4eed8c4b41b845a5b98f5a8d3 Mon Sep 17 00:00:00 2001 From: Terry Smith Date: Sat, 13 Oct 2018 16:26:16 -0600 Subject: [PATCH 1/3] Regenerate v1 and v2 APIs using latest Swagger specifications Remove unnamed field and decrease minimum number of bad login attempts --- config_v1.json | 2 +- config_v2.json | 2 +- jcapiv1/README.md | 9 +- jcapiv1/docs/Command.md | 2 +- jcapiv1/docs/CommandslistResults.md | 2 +- jcapiv1/docs/OrganizationslistResults.md | 2 +- jcapiv1/docs/Systemuser.md | 2 +- jcapiv1/docs/SystemuserAttributes.md | 8 - jcapiv1/lib/jcapiv1.rb | 1 - jcapiv1/lib/jcapiv1/models/command.rb | 2 +- .../jcapiv1/models/commandslist_results.rb | 2 +- .../models/organizationslist_results.rb | 2 +- jcapiv1/lib/jcapiv1/models/systemuser.rb | 2 +- .../jcapiv1/models/systemuser_attributes.rb | 188 ------------------ .../lib/jcapiv1/models/systemuserreturn.rb | 10 +- jcapiv1/lib/jcapiv1/version.rb | 2 +- .../spec/models/systemuser_attributes_spec.rb | 42 ---- jcapiv2/README.md | 9 +- jcapiv2/docs/Systemuser.md | 2 +- jcapiv2/docs/SystemuserAttributes.md | 8 - jcapiv2/lib/jcapiv2.rb | 1 - jcapiv2/lib/jcapiv2/models/systemuser.rb | 2 +- .../jcapiv2/models/systemuser_attributes.rb | 188 ------------------ jcapiv2/lib/jcapiv2/version.rb | 2 +- .../spec/models/systemuser_attributes_spec.rb | 42 ---- 25 files changed, 27 insertions(+), 507 deletions(-) delete mode 100644 jcapiv1/docs/SystemuserAttributes.md delete mode 100644 jcapiv1/lib/jcapiv1/models/systemuser_attributes.rb delete mode 100644 jcapiv1/spec/models/systemuser_attributes_spec.rb delete mode 100644 jcapiv2/docs/SystemuserAttributes.md delete mode 100644 jcapiv2/lib/jcapiv2/models/systemuser_attributes.rb delete mode 100644 jcapiv2/spec/models/systemuser_attributes_spec.rb diff --git a/config_v1.json b/config_v1.json index ff135c2..e2de389 100644 --- a/config_v1.json +++ b/config_v1.json @@ -1,5 +1,5 @@ { "gemName": "jcapiv1", "moduleName": "JCAPIv1", - "gemVersion": "1.1.0" + "gemVersion": "1.2.0" } diff --git a/config_v2.json b/config_v2.json index de487ce..a86e622 100644 --- a/config_v2.json +++ b/config_v2.json @@ -1,5 +1,5 @@ { "gemName": "jcapiv2", "moduleName": "JCAPIv2", - "gemVersion": "1.1.0" + "gemVersion": "1.2.0" } diff --git a/jcapiv1/README.md b/jcapiv1/README.md index 59abc4e..415aa90 100644 --- a/jcapiv1/README.md +++ b/jcapiv1/README.md @@ -7,7 +7,7 @@ JCAPIv1 - the Ruby gem for the JumpCloud APIs This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.0 -- Package version: 1.1.0 +- Package version: 1.2.0 - Build package: io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -23,15 +23,15 @@ gem build jcapiv1.gemspec Then either install the gem locally: ```shell -gem install ./jcapiv1-1.1.0.gem +gem install ./jcapiv1-1.2.0.gem ``` -(for development, run `gem install --dev ./jcapiv1-1.1.0.gem` to install the development dependencies) +(for development, run `gem install --dev ./jcapiv1-1.2.0.gem` to install the development dependencies) or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). Finally add this to the Gemfile: - gem 'jcapiv1', '~> 1.1.0' + gem 'jcapiv1', '~> 1.2.0' ### Install from Git @@ -172,7 +172,6 @@ Class | Method | HTTP request | Description - [JCAPIv1::SystemputAgentBoundMessages](docs/SystemputAgentBoundMessages.md) - [JCAPIv1::Systemslist](docs/Systemslist.md) - [JCAPIv1::Systemuser](docs/Systemuser.md) - - [JCAPIv1::SystemuserAttributes](docs/SystemuserAttributes.md) - [JCAPIv1::Systemuserbinding](docs/Systemuserbinding.md) - [JCAPIv1::Systemuserbindingsput](docs/Systemuserbindingsput.md) - [JCAPIv1::Systemuserput](docs/Systemuserput.md) diff --git a/jcapiv1/docs/Command.md b/jcapiv1/docs/Command.md index a5f7278..40d9d71 100644 --- a/jcapiv1/docs/Command.md +++ b/jcapiv1/docs/Command.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes **name** | **String** | | [optional] **command** | **String** | The command to execute on the server. | **command_type** | **String** | The Command OS | [optional] -**command_runners** | **Array<String>** | an array of IDs of the Command Runner Users that can execute this command. | [optional] +**command_runners** | **Array<String>** | An array of IDs of the Command Runner Users that can execute this command. | [optional] **user** | **String** | The ID of the system user to run the command as. | **sudo** | **BOOLEAN** | | [optional] **systems** | **Array<String>** | An array of system IDs to run the command on. Not available if you are using Groups. | [optional] diff --git a/jcapiv1/docs/CommandslistResults.md b/jcapiv1/docs/CommandslistResults.md index 962860e..563b474 100644 --- a/jcapiv1/docs/CommandslistResults.md +++ b/jcapiv1/docs/CommandslistResults.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **launch_type** | **String** | How the Command is executed. | [optional] **listens_to** | **String** | | [optional] **schedule** | **String** | A crontab that consists of: [ (seconds) (minutes) (hours) (days of month) (months) (weekdays) ] or [ immediate ]. If you send this as an empty string, it will run immediately. | [optional] -**trigger** | **String** | trigger to execute command. | [optional] +**trigger** | **String** | Trigger to execute command. | [optional] **schedule_repeat_type** | **String** | When the command will repeat. | [optional] **organization** | **String** | The ID of the Organization. | [optional] **_id** | **String** | The ID of the command. | [optional] diff --git a/jcapiv1/docs/OrganizationslistResults.md b/jcapiv1/docs/OrganizationslistResults.md index 628d7d1..82aad65 100644 --- a/jcapiv1/docs/OrganizationslistResults.md +++ b/jcapiv1/docs/OrganizationslistResults.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**_id** | **String** | the ID of the organization. | [optional] +**_id** | **String** | The ID of the organization. | [optional] **display_name** | **String** | The name of the organization. | [optional] **logo_url** | **String** | The organization logo image URL. | [optional] diff --git a/jcapiv1/docs/Systemuser.md b/jcapiv1/docs/Systemuser.md index 0b88b9b..a920c74 100644 --- a/jcapiv1/docs/Systemuser.md +++ b/jcapiv1/docs/Systemuser.md @@ -27,7 +27,7 @@ Name | Type | Description | Notes **associated_tag_count** | **Integer** | | [optional] **totp_enabled** | **BOOLEAN** | | [optional] **password_expiration_date** | **String** | | [optional] -**attributes** | [**Array<SystemuserAttributes>**](SystemuserAttributes.md) | | [optional] +**attributes** | **Array<Object>** | | [optional] **created** | **String** | | [optional] **samba_service_user** | **BOOLEAN** | | [optional] **password_never_expires** | **BOOLEAN** | | [optional] diff --git a/jcapiv1/docs/SystemuserAttributes.md b/jcapiv1/docs/SystemuserAttributes.md deleted file mode 100644 index 4497385..0000000 --- a/jcapiv1/docs/SystemuserAttributes.md +++ /dev/null @@ -1,8 +0,0 @@ -# JCAPIv1::SystemuserAttributes - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**** | **String** | | [optional] - - diff --git a/jcapiv1/lib/jcapiv1.rb b/jcapiv1/lib/jcapiv1.rb index babaf6c..a461b3b 100644 --- a/jcapiv1/lib/jcapiv1.rb +++ b/jcapiv1/lib/jcapiv1.rb @@ -53,7 +53,6 @@ require 'jcapiv1/models/systemput_agent_bound_messages' require 'jcapiv1/models/systemslist' require 'jcapiv1/models/systemuser' -require 'jcapiv1/models/systemuser_attributes' require 'jcapiv1/models/systemuserbinding' require 'jcapiv1/models/systemuserbindingsput' require 'jcapiv1/models/systemuserput' diff --git a/jcapiv1/lib/jcapiv1/models/command.rb b/jcapiv1/lib/jcapiv1/models/command.rb index 62e2ab6..1b3b685 100644 --- a/jcapiv1/lib/jcapiv1/models/command.rb +++ b/jcapiv1/lib/jcapiv1/models/command.rb @@ -23,7 +23,7 @@ class Command # The Command OS attr_accessor :command_type - # an array of IDs of the Command Runner Users that can execute this command. + # An array of IDs of the Command Runner Users that can execute this command. attr_accessor :command_runners # The ID of the system user to run the command as. diff --git a/jcapiv1/lib/jcapiv1/models/commandslist_results.rb b/jcapiv1/lib/jcapiv1/models/commandslist_results.rb index 2a2acc1..7c21ae6 100644 --- a/jcapiv1/lib/jcapiv1/models/commandslist_results.rb +++ b/jcapiv1/lib/jcapiv1/models/commandslist_results.rb @@ -33,7 +33,7 @@ class CommandslistResults # A crontab that consists of: [ (seconds) (minutes) (hours) (days of month) (months) (weekdays) ] or [ immediate ]. If you send this as an empty string, it will run immediately. attr_accessor :schedule - # trigger to execute command. + # Trigger to execute command. attr_accessor :trigger # When the command will repeat. diff --git a/jcapiv1/lib/jcapiv1/models/organizationslist_results.rb b/jcapiv1/lib/jcapiv1/models/organizationslist_results.rb index 69db4b8..3e73dd9 100644 --- a/jcapiv1/lib/jcapiv1/models/organizationslist_results.rb +++ b/jcapiv1/lib/jcapiv1/models/organizationslist_results.rb @@ -15,7 +15,7 @@ module JCAPIv1 class OrganizationslistResults - # the ID of the organization. + # The ID of the organization. attr_accessor :_id # The name of the organization. diff --git a/jcapiv1/lib/jcapiv1/models/systemuser.rb b/jcapiv1/lib/jcapiv1/models/systemuser.rb index 51d68ee..81dbc5a 100644 --- a/jcapiv1/lib/jcapiv1/models/systemuser.rb +++ b/jcapiv1/lib/jcapiv1/models/systemuser.rb @@ -167,7 +167,7 @@ def self.swagger_types :'associated_tag_count' => :'Integer', :'totp_enabled' => :'BOOLEAN', :'password_expiration_date' => :'String', - :'attributes' => :'Array', + :'attributes' => :'Array', :'created' => :'String', :'samba_service_user' => :'BOOLEAN', :'password_never_expires' => :'BOOLEAN', diff --git a/jcapiv1/lib/jcapiv1/models/systemuser_attributes.rb b/jcapiv1/lib/jcapiv1/models/systemuser_attributes.rb deleted file mode 100644 index 310697b..0000000 --- a/jcapiv1/lib/jcapiv1/models/systemuser_attributes.rb +++ /dev/null @@ -1,188 +0,0 @@ -=begin -#JumpCloud APIs - -# JumpCloud's V1 API. This set of endpoints allows JumpCloud customers to manage commands, systems, & system users. - -OpenAPI spec version: 1.0 - -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.1 - -=end - -require 'date' - -module JCAPIv1 - - class SystemuserAttributes - attr_accessor : - - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'' => :'' - } - end - - # Attribute type mapping. - def self.swagger_types - { - :'' => :'String' - } - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - - if attributes.has_key?(:'') - self. = attributes[:''] - end - - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - return invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - == o. - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Fixnum] Hash code - def hash - [].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.swagger_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :BOOLEAN - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - temp_model = JCAPIv1.const_get(type).new - temp_model.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - next if value.nil? - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map{ |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - - end - -end diff --git a/jcapiv1/lib/jcapiv1/models/systemuserreturn.rb b/jcapiv1/lib/jcapiv1/models/systemuserreturn.rb index 63f7eed..0b50a9f 100644 --- a/jcapiv1/lib/jcapiv1/models/systemuserreturn.rb +++ b/jcapiv1/lib/jcapiv1/models/systemuserreturn.rb @@ -423,8 +423,8 @@ def list_invalid_properties invalid_properties.push("invalid value for 'department', the character length must be smaller than or equal to 1024.") end - if !@bad_login_attempts.nil? && @bad_login_attempts < 1 - invalid_properties.push("invalid value for 'bad_login_attempts', must be greater than or equal to 1.") + if !@bad_login_attempts.nil? && @bad_login_attempts < 0 + invalid_properties.push("invalid value for 'bad_login_attempts', must be greater than or equal to 0.") end if !@middlename.nil? && @middlename.to_s.length > 1024 @@ -473,7 +473,7 @@ def valid? return false if !@lastname.nil? && @lastname.to_s.length > 1024 return false if !@job_title.nil? && @job_title.to_s.length > 1024 return false if !@department.nil? && @department.to_s.length > 1024 - return false if !@bad_login_attempts.nil? && @bad_login_attempts < 1 + return false if !@bad_login_attempts.nil? && @bad_login_attempts < 0 return false if !@middlename.nil? && @middlename.to_s.length > 1024 return false if !@displayname.nil? && @displayname.to_s.length > 1024 return false if !@description.nil? && @description.to_s.length > 1024 @@ -577,8 +577,8 @@ def department=(department) # @param [Object] bad_login_attempts Value to be assigned def bad_login_attempts=(bad_login_attempts) - if !bad_login_attempts.nil? && bad_login_attempts < 1 - fail ArgumentError, "invalid value for 'bad_login_attempts', must be greater than or equal to 1." + if !bad_login_attempts.nil? && bad_login_attempts < 0 + fail ArgumentError, "invalid value for 'bad_login_attempts', must be greater than or equal to 0." end @bad_login_attempts = bad_login_attempts diff --git a/jcapiv1/lib/jcapiv1/version.rb b/jcapiv1/lib/jcapiv1/version.rb index 8427757..ce00538 100644 --- a/jcapiv1/lib/jcapiv1/version.rb +++ b/jcapiv1/lib/jcapiv1/version.rb @@ -11,5 +11,5 @@ =end module JCAPIv1 - VERSION = "1.1.0" + VERSION = "1.2.0" end diff --git a/jcapiv1/spec/models/systemuser_attributes_spec.rb b/jcapiv1/spec/models/systemuser_attributes_spec.rb deleted file mode 100644 index 28e438e..0000000 --- a/jcapiv1/spec/models/systemuser_attributes_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -=begin -#JumpCloud APIs - -# JumpCloud's V1 API. This set of endpoints allows JumpCloud customers to manage commands, systems, & system users. - -OpenAPI spec version: 1.0 - -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.1 - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for JCAPIv1::SystemuserAttributes -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'SystemuserAttributes' do - before do - # run before each test - @instance = JCAPIv1::SystemuserAttributes.new - end - - after do - # run after each test - end - - describe 'test an instance of SystemuserAttributes' do - it 'should create an instance of SystemuserAttributes' do - expect(@instance).to be_instance_of(JCAPIv1::SystemuserAttributes) - end - end - describe 'test attribute ""' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end - diff --git a/jcapiv2/README.md b/jcapiv2/README.md index 3858f5a..c1ad0b7 100644 --- a/jcapiv2/README.md +++ b/jcapiv2/README.md @@ -7,7 +7,7 @@ JCAPIv2 - the Ruby gem for the JumpCloud APIs This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 2.0 -- Package version: 1.1.0 +- Package version: 1.2.0 - Build package: io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -23,15 +23,15 @@ gem build jcapiv2.gemspec Then either install the gem locally: ```shell -gem install ./jcapiv2-1.1.0.gem +gem install ./jcapiv2-1.2.0.gem ``` -(for development, run `gem install --dev ./jcapiv2-1.1.0.gem` to install the development dependencies) +(for development, run `gem install --dev ./jcapiv2-1.2.0.gem` to install the development dependencies) or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). Finally add this to the Gemfile: - gem 'jcapiv2', '~> 1.1.0' + gem 'jcapiv2', '~> 1.2.0' ### Install from Git @@ -368,7 +368,6 @@ Class | Method | HTTP request | Description - [JCAPIv2::SystemGroupMembersReq](docs/SystemGroupMembersReq.md) - [JCAPIv2::Systemfdekey](docs/Systemfdekey.md) - [JCAPIv2::Systemuser](docs/Systemuser.md) - - [JCAPIv2::SystemuserAttributes](docs/SystemuserAttributes.md) - [JCAPIv2::Systemuserputpost](docs/Systemuserputpost.md) - [JCAPIv2::SystemuserputpostAddresses](docs/SystemuserputpostAddresses.md) - [JCAPIv2::SystemuserputpostPhoneNumbers](docs/SystemuserputpostPhoneNumbers.md) diff --git a/jcapiv2/docs/Systemuser.md b/jcapiv2/docs/Systemuser.md index 6931695..81420cd 100644 --- a/jcapiv2/docs/Systemuser.md +++ b/jcapiv2/docs/Systemuser.md @@ -27,7 +27,7 @@ Name | Type | Description | Notes **associated_tag_count** | **Integer** | | [optional] **totp_enabled** | **BOOLEAN** | | [optional] **password_expiration_date** | **String** | | [optional] -**attributes** | [**Array<SystemuserAttributes>**](SystemuserAttributes.md) | | [optional] +**attributes** | **Array<Object>** | | [optional] **created** | **String** | | [optional] **samba_service_user** | **BOOLEAN** | | [optional] **password_never_expires** | **BOOLEAN** | | [optional] diff --git a/jcapiv2/docs/SystemuserAttributes.md b/jcapiv2/docs/SystemuserAttributes.md deleted file mode 100644 index a671caf..0000000 --- a/jcapiv2/docs/SystemuserAttributes.md +++ /dev/null @@ -1,8 +0,0 @@ -# JCAPIv2::SystemuserAttributes - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**** | **String** | | [optional] - - diff --git a/jcapiv2/lib/jcapiv2.rb b/jcapiv2/lib/jcapiv2.rb index dfa735f..4a378e6 100644 --- a/jcapiv2/lib/jcapiv2.rb +++ b/jcapiv2/lib/jcapiv2.rb @@ -62,7 +62,6 @@ require 'jcapiv2/models/system_group_members_req' require 'jcapiv2/models/systemfdekey' require 'jcapiv2/models/systemuser' -require 'jcapiv2/models/systemuser_attributes' require 'jcapiv2/models/systemuserputpost' require 'jcapiv2/models/systemuserputpost_addresses' require 'jcapiv2/models/systemuserputpost_phone_numbers' diff --git a/jcapiv2/lib/jcapiv2/models/systemuser.rb b/jcapiv2/lib/jcapiv2/models/systemuser.rb index d5612b2..94a11c1 100644 --- a/jcapiv2/lib/jcapiv2/models/systemuser.rb +++ b/jcapiv2/lib/jcapiv2/models/systemuser.rb @@ -167,7 +167,7 @@ def self.swagger_types :'associated_tag_count' => :'Integer', :'totp_enabled' => :'BOOLEAN', :'password_expiration_date' => :'String', - :'attributes' => :'Array', + :'attributes' => :'Array', :'created' => :'String', :'samba_service_user' => :'BOOLEAN', :'password_never_expires' => :'BOOLEAN', diff --git a/jcapiv2/lib/jcapiv2/models/systemuser_attributes.rb b/jcapiv2/lib/jcapiv2/models/systemuser_attributes.rb deleted file mode 100644 index bbf0831..0000000 --- a/jcapiv2/lib/jcapiv2/models/systemuser_attributes.rb +++ /dev/null @@ -1,188 +0,0 @@ -=begin -#JumpCloud APIs - -# JumpCloud's V2 API. This set of endpoints allows JumpCloud customers to manage objects, groupings and mappings and interact with the JumpCloud Graph. - -OpenAPI spec version: 2.0 - -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.1 - -=end - -require 'date' - -module JCAPIv2 - - class SystemuserAttributes - attr_accessor : - - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'' => :'' - } - end - - # Attribute type mapping. - def self.swagger_types - { - :'' => :'String' - } - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - - if attributes.has_key?(:'') - self. = attributes[:''] - end - - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - return invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - == o. - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Fixnum] Hash code - def hash - [].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.swagger_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :BOOLEAN - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - temp_model = JCAPIv2.const_get(type).new - temp_model.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - next if value.nil? - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map{ |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - - end - -end diff --git a/jcapiv2/lib/jcapiv2/version.rb b/jcapiv2/lib/jcapiv2/version.rb index 7662fc7..f408a3d 100644 --- a/jcapiv2/lib/jcapiv2/version.rb +++ b/jcapiv2/lib/jcapiv2/version.rb @@ -11,5 +11,5 @@ =end module JCAPIv2 - VERSION = "1.1.0" + VERSION = "1.2.0" end diff --git a/jcapiv2/spec/models/systemuser_attributes_spec.rb b/jcapiv2/spec/models/systemuser_attributes_spec.rb deleted file mode 100644 index 412b4d0..0000000 --- a/jcapiv2/spec/models/systemuser_attributes_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -=begin -#JumpCloud APIs - -# JumpCloud's V2 API. This set of endpoints allows JumpCloud customers to manage objects, groupings and mappings and interact with the JumpCloud Graph. - -OpenAPI spec version: 2.0 - -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.1 - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for JCAPIv2::SystemuserAttributes -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) -# Please update as you see appropriate -describe 'SystemuserAttributes' do - before do - # run before each test - @instance = JCAPIv2::SystemuserAttributes.new - end - - after do - # run after each test - end - - describe 'test an instance of SystemuserAttributes' do - it 'should create an instance of SystemuserAttributes' do - expect(@instance).to be_instance_of(JCAPIv2::SystemuserAttributes) - end - end - describe 'test attribute ""' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end - From a62676b1c8b021b83d2a636cee9a6014a7364b9f Mon Sep 17 00:00:00 2001 From: Terry Smith Date: Mon, 15 Oct 2018 22:49:46 -0600 Subject: [PATCH 2/3] Ignore Ruby artifacts --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7da84b6..5acee40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Ruby artifacts +*.gem + # input and output directories input output From bb7bf266efc4358880293391ddb8351a3eb7197e Mon Sep 17 00:00:00 2001 From: Terry Smith Date: Mon, 15 Oct 2018 23:07:30 -0600 Subject: [PATCH 3/3] Update readme and code examples --- README.md | 175 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 951585a..91295be 100644 --- a/README.md +++ b/README.md @@ -1,167 +1,190 @@ ## JCAPI-Ruby -### Description ### +### Description -This repository contains the Ruby client code for the JumpCloud API v1 and v2. -It also provides the tools to generate the client code from the API yaml files, using swagger-codegen. -For detailed instructions on how to generate the code, see the [Contributing](CONTRIBUTING.md) section. +This repository contains the Ruby client code for the JumpCloud API v1 and +v2. It also provides the tools to generate the client code from the API YAML +files, using Swagger Codegen. For detailed instructions on how to generate the +code, see the [Contributing](CONTRIBUTING.md) section. ### Installing the Ruby Client -#### Installing from github with Bundler +#### Installing from GitHub with Bundler Add the following line(s) to your Gemfile: -`gem 'jcapiv1', :git => 'https://github.com/TheJumpCloud/jcapi-ruby.git'` for the jcapiv1 gem +`gem 'jcapiv1', :git => 'https://github.com/TheJumpCloud/jcapi-ruby.git'` for the jcapiv1 gem. -`gem 'jcapiv2', :git => 'https://github.com/TheJumpCloud/jcapi-ruby.git'` for the jcapiv2 gem +`gem 'jcapiv2', :git => 'https://github.com/TheJumpCloud/jcapi-ruby.git'` for the jcapiv2 gem. -And run: `bundle install` +And run: `bundle install`. -#### Manual install +#### Manual Install Change to the appropriate directory (jcapiv1 or jcapiv2) and then run the following -commands to build/install the Ruby Client API package: +commands to build/install the Ruby client API package: To build the Ruby code into a gem: + ```shell gem build jcapiv1.gemspec ``` + Then either install the gem locally: + ```shell gem install --user-install ./jcapiv1-1.0.0.gem ``` + Or for all users: + ```shell -$ sudo gem install ./jcapiv1-1.0.0.gem +sudo gem install ./jcapiv1-1.0.0.gem ``` ### Authentication and Authorization -All endpoints support authentication via API key: see the [Authentication and Authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/authentication-and-authorization-overview) -section in our API docs. - -Some Systems endpoints (in both API v1 and v2) also support the [System Context authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context) -which allows an individual system to manage its information and resource associations. +All endpoints support authentication via API key: see the +[Authentication & Authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/authentication-and-authorization-overview) +section in our API documentation. +Some systems endpoints (in both API v1 and v2) also support +[System Context Authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context) +which allows an individual system to manage its information and resource +associations. ### Usage Examples -For more detailed instructions, refer to each API's respective README file -([README for API v1](jcapiv1/README.md) and [README for API v2](jcapiv2/README.md)) -and the generated docs under each folder. +For more detailed instructions, refer to each API version's respective README +file ([README for API v1](jcapiv1/README.md) and +[README for API v2](jcapiv2/README.md)) and the generated documentation under +each folder. + +#### API v1 Example -#### API v1 example: ```ruby #!/usr/bin/env ruby -# Load the gem require 'jcapiv1' -# Setup API key: -JCAPIv1.configure do |config| - # Configure API key authorization: x-api-key - config.api_key['x-api-key'] = '' -end - -# instantiate the Systemusers API object: -api_instance = JCAPIv1::SystemusersApi.new +api_key = 'YOUR_API_KEY' +system_user_id = 'YOUR_SYSTEM_USER_ID' content_type = 'application/json' accept = 'application/json' +# Set up the configuration object with your API key for authorization. +JCAPIv1.configure do |config| + config.api_key['x-api-key'] = api_key +end + +# Instantiate the API object for the group of endpoints you need to use, +# for instance the system users API. +system_users_api = JCAPIv1::SystemusersApi.new -# Example 1: print all users: +# Example 1: Make an API call to retrieve system users. opts = { limit: 100, # The number of records to return at once. - sort: 'username' # sort by username + sort: 'username' } begin - res = api_instance.systemusers_list(content_type, accept, opts) - puts res.total_count - puts res.results + response = system_users_api.systemusers_list(content_type, accept, opts) + puts response rescue JCAPIv1::ApiError => e - puts 'Exception when calling SystemusersApi->systemusers_list: #{e}' + puts "Exception when calling SystemusersApi->systemusers_list: #{e}" end +# Example 2: Make an API call to update a system user. -# Example 2: modify the lastname of a specific user: - -# create a put request with the updated last name: -put_request = JCAPIv1::Systemuserputpost.new -put_request.lastname = 'updated last name' -# pass the request in the optional parameters: -opts = { - body: put_request -} +put_request = JCAPIv1::Systemuserput.new +put_request.lastname = 'Updated Last Name' +opts = { body: put_request } begin - res = api_instance.systemusers_put('', content_type, accept, opts) - puts res + response = system_users_api.systemusers_put( + system_user_id, content_type, accept, opts + ) + puts response rescue JCAPIv1::ApiError => e - puts 'Exception when calling SystemusersApi->systemusers_get: #{e}' + puts "Exception when calling SystemusersApi->systemusers_put: #{e}" end ``` -#### API v2 example: +#### API v2 Example + ```ruby #!/usr/bin/env ruby -# Load the gem require 'jcapiv2' -# Setup API key: +api_key = 'YOUR_API_KEY' + +content_type = 'application/json' +accept = 'application/json' + +# Set up the configuration object with your API key for authorization JCAPIv2.configure do |config| - # Configure API key authorization: x-api-key - config.api_key['x-api-key'] = '' + config.api_key['x-api-key'] = api_key end -# instantiate the UserGroups API object: -api_instance = JCAPIv2::UserGroupsApi.new +# Instantiate the API object for the group of endpoints you need to use, +# for instance the user groups API. +user_groups_api = JCAPIv2::UserGroupsApi.new -content_type = 'application/json' -accept = 'application/json' +# Make an API call to retrieve user groups. -# print all user groups: begin - res = api_instance.groups_user_list(content_type, accept) - puts res + response = user_groups_api.groups_user_list(content_type, accept) + puts response rescue JCAPIv2::ApiError => e - puts 'Exception when calling UserGroupsApi->groups_user_list: #{e}' + puts "Exception when calling UserGroupsApi->groups_user_list: #{e}" end + ``` -#### System Context API example: +#### System Context Authorization Example + ```ruby #!/usr/bin/env ruby -# Load the gem require 'jcapiv2' -# instantiate the Systems API object: -api_instance = JCAPIv2::SystemsApi.new +# Set headers for System Context Authorization. For detailed instructions on +# how to generate these headers, refer to: +# https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context +system_id = 'YOUR_SYSTEM_ID' +# The current date on the system, e.g. 'Fri, 16 Jan 1998 12:13:05 GMT' +system_date = 'YOUR_SYSTEM_DATE' +system_signature = 'YOUR_SYSTEM_SIGNATURE' +system_context_auth = \ + "Signature keyId=\"system/#{system_id}\","\ + 'headers="request-line date",'\ + 'algorithm="rsa-sha256",'\ + "signature=\"#{system_signature}\"" content_type = 'application/json' accept = 'application/json' -system_id = '' -# set headers for the System Context Authorization: -# for detailed instructions on how to generate these headers, -# refer to: https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context -opts = { - authorization: 'Signature keyId="system/",headers="request-line date",algorithm="rsa-sha256",signature=""', - date: 'Thu, 19 Oct 2017 17:27:57 GMT' # the current date on the system -} + +# Instantiate the API object for the group of endpoints you need to use, +# for instance the user groups API. +systems_api = JCAPIv2::SystemsApi.new + +# Make an API call to retrieve all system groups this system is a member of. + +opts = { authorization: system_context_auth, date: system_date } begin - # list the system groups this system is a member of: - res = api_instance.graph_system_member_of(system_id, content_type, accept, opts) - puts res + response = systems_api.graph_system_member_of( + system_id, content_type, accept, opts + ) + puts response rescue JCAPIv2::ApiError => e - puts 'Exception when calling systemsAPI->graph_system_member_of: #{e}' + puts "Exception when calling systemsAPI->graph_system_member_of: #{e}" end + ```