Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from TheJumpCloud/ts-updates-2018-10-13
Browse files Browse the repository at this point in the history
API v1 and v2 updates 2018-10-13
  • Loading branch information
tsmithjc committed Oct 17, 2018
2 parents 80cd311 + bb7bf26 commit 0407738
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 583 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ruby artifacts
*.gem

# input and output directories
input
output
175 changes: 99 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -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'] = '<YOUR_JUMPCLOUD_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('<YOUR_USER_ID>', 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'] = '<YOUR_JUMPCLOUD_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 = '<YOUR_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/<YOUR_SYSTEM_ID>",headers="request-line date",algorithm="rsa-sha256",signature="<YOUR_SYSTEM_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

```
2 changes: 1 addition & 1 deletion config_v1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gemName": "jcapiv1",
"moduleName": "JCAPIv1",
"gemVersion": "1.1.0"
"gemVersion": "1.2.0"
}
2 changes: 1 addition & 1 deletion config_v2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"gemName": "jcapiv2",
"moduleName": "JCAPIv2",
"gemVersion": "1.1.0"
"gemVersion": "1.2.0"
}
9 changes: 4 additions & 5 deletions jcapiv1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion jcapiv1/docs/Command.md
Original file line number Diff line number Diff line change
Expand Up @@ -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&lt;String&gt;** | an array of IDs of the Command Runner Users that can execute this command. | [optional]
**command_runners** | **Array&lt;String&gt;** | 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&lt;String&gt;** | An array of system IDs to run the command on. Not available if you are using Groups. | [optional]
Expand Down
2 changes: 1 addition & 1 deletion jcapiv1/docs/CommandslistResults.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion jcapiv1/docs/OrganizationslistResults.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion jcapiv1/docs/Systemuser.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Name | Type | Description | Notes
**associated_tag_count** | **Integer** | | [optional]
**totp_enabled** | **BOOLEAN** | | [optional]
**password_expiration_date** | **String** | | [optional]
**attributes** | [**Array&lt;SystemuserAttributes&gt;**](SystemuserAttributes.md) | | [optional]
**attributes** | **Array&lt;Object&gt;** | | [optional]
**created** | **String** | | [optional]
**samba_service_user** | **BOOLEAN** | | [optional]
**password_never_expires** | **BOOLEAN** | | [optional]
Expand Down
8 changes: 0 additions & 8 deletions jcapiv1/docs/SystemuserAttributes.md

This file was deleted.

1 change: 0 additions & 1 deletion jcapiv1/lib/jcapiv1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion jcapiv1/lib/jcapiv1/models/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion jcapiv1/lib/jcapiv1/models/commandslist_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 0407738

Please sign in to comment.