-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V2 #7
V2 #7
Changes from 18 commits
debd5f8
72ef22b
176c64f
c4aa138
9cca5ca
2d9e461
5c2c36c
8b67e71
f2cf974
6d03865
9d85272
b9dd0b6
44e3d86
4659aa4
14a40e3
935d7fa
fbd7ab1
fb0d8b7
3516696
4d9f157
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
bin/ | ||
vendor/ | ||
doc/ | ||
.DS_Store | ||
.ruby-version | ||
coverage | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ rvm: | |
- 2.2.1 | ||
|
||
script: ./build_travis.sh | ||
|
||
after_success: ./deploy_documentation.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# exit with nonzero exit code if anything fails | ||
set -e | ||
|
||
# clear and re-create the out directory | ||
rm -rf doc || exit 0; | ||
mkdir doc; | ||
|
||
# build documentation | ||
bundle exec rake documentation | ||
|
||
# go to the out directory and create a *new* Git repo | ||
cd doc | ||
git init | ||
|
||
# inside this git repo we'll pretend to be a new user | ||
git config user.name "Travis CI" | ||
git config user.email "[email protected]" | ||
|
||
# The first and only commit to this new Git repo contains all the | ||
# files present with the commit message "Deploy to GitHub Pages". | ||
git add . | ||
git commit -m "Deploy to GitHub Pages" | ||
|
||
# Force push from the current repo's master branch to the remote | ||
# repo's gh-pages branch. (All previous history on the gh-pages branch | ||
# will be lost, since we are overwriting it.) We redirect any output to | ||
# /dev/null to hide any sensitive credential data that might otherwise be exposed. | ||
git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" master:gh-pages > /dev/null 2>&1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
require 'auth0/api/v2/clients' | ||
require 'auth0/api/v2/users' | ||
require 'auth0/api/v2/blacklists' | ||
require 'auth0/api/v2/clients' | ||
require 'auth0/api/v2/connections' | ||
require 'auth0/api/v2/emails' | ||
require 'auth0/api/v2/jobs' | ||
require 'auth0/api/v2/rules' | ||
require 'auth0/api/v2/stats' | ||
require 'auth0/api/v2/connections' | ||
require 'auth0/api/v2/users' | ||
require 'auth0/api/v2/tenants' | ||
require 'auth0/api/v2/tickets' | ||
|
||
module Auth0 | ||
module Api | ||
# https://auth0.com/docs/apiv2 | ||
module V2 | ||
include Auth0::Api::V2::Clients | ||
include Auth0::Api::V2::Users | ||
include Auth0::Api::V2::Blacklists | ||
include Auth0::Api::V2::Clients | ||
include Auth0::Api::V2::Connections | ||
include Auth0::Api::V2::Emails | ||
include Auth0::Api::V2::Jobs | ||
include Auth0::Api::V2::Rules | ||
include Auth0::Api::V2::Stats | ||
include Auth0::Api::V2::Connections | ||
include Auth0::Api::V2::Users | ||
include Auth0::Api::V2::Tenants | ||
include Auth0::Api::V2::Tickets | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
module Auth0 | ||
module Api | ||
module V2 | ||
# https://auth0.com/docs/api/v2#!/Connections | ||
# Methods to use the connections endpoints | ||
module Connections | ||
# Retrieves every connection matching the specified strategy. All connections are retrieved if no strategy is | ||
# being specified. Accepts a list of fields to include or exclude in the resulting list of connection objects. | ||
# @see https://auth0.com/docs/api/v2#!/Connections/get_connections | ||
# @param strategy [string] Provide a type of strategy to only retrieve connections with that strategy | ||
# @param fields [string] A comma separated list of fields to include or exclude from the result. | ||
# @param include_fields [boolean] if the fields specified are to be included in the result, false otherwise. | ||
# | ||
# @return [json] Returns the existing connections matching the strategy. | ||
def connections(strategy: nil, fields: nil, include_fields: true) | ||
request_params = { | ||
strategy: strategy, | ||
|
@@ -14,13 +22,27 @@ def connections(strategy: nil, fields: nil, include_fields: true) | |
end | ||
alias_method :get_connections, :connections | ||
|
||
# Creates a new connection according to the JSON object received in body. | ||
# @see https://auth0.com/docs/api/v2#!/Connections/post_connections | ||
# @param body [hash] The Hash options used to define the conecctions's properties. | ||
# | ||
# @return [json] Returns the created connection. | ||
def create_connection(body) | ||
fail Auth0::InvalidParameter, 'Must specify a body to create a connection' if body.to_s.empty? | ||
path = '/api/v2/connections' | ||
request_params = body | ||
post(path, request_params) | ||
end | ||
|
||
# Retrieves a connection by its id. | ||
# @see https://auth0.com/docs/api/v2#!/Connections/get_connections_by_id | ||
# @param connection_id [string] The id of the connection to retrieve | ||
# @param fields [string] A comma separated list of fields to include or exclude from the result. | ||
# @param include_fields [boolean] if the fields specified are to be included in the result, false otherwise | ||
# | ||
# @return [json] Returns the matching connection | ||
def connection(connection_id, fields: nil, include_fields: true) | ||
fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? | ||
path = "/api/v2/connections/#{connection_id}" | ||
request_params = { | ||
fields: fields, | ||
|
@@ -29,14 +51,37 @@ def connection(connection_id, fields: nil, include_fields: true) | |
get(path, request_params) | ||
end | ||
|
||
# Deletes a connection and all its users. | ||
# @see https://auth0.com/docs/api/v2#!/Connections/delete_connections_by_id | ||
# @param connection_id [string] The id of the connection to delete | ||
def delete_connection(connection_id) | ||
fail Auth0::MissingConnectionId, 'you must specify a connection id' if connection_id.to_s.empty? | ||
fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? | ||
path = "/api/v2/connections/#{connection_id}" | ||
delete(path) | ||
end | ||
|
||
# Deletes a specified connection user by its email (currently only database connections are supported and you | ||
# cannot delete all users from specific connection). | ||
# @see https://auth0.com/docs/api/v2#!/Connections/delete_users | ||
# @param connection_id [string] The id of the connection | ||
# @param user_email [string] The email of the user to delete | ||
# | ||
# @return [json] Returns the updated connection. | ||
def delete_connection_user(connection_id, user_email) | ||
fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? | ||
fail Auth0::InvalidParameter, 'Must supply a valid user email' if user_email.to_s.empty? | ||
path = "/api/v2/connections/#{connection_id}/users?email=#{user_email}" | ||
delete(path) | ||
end | ||
|
||
# Updates a connection. Updates the fields specified in the body parameter. | ||
# @see https://auth0.com/docs/api/v2#!/Connections/patch_connections_by_id | ||
# @param connection_id [string] The id of the connection to delete | ||
# @param body [hash] The Hash options used to update the conecctions's properties. | ||
# | ||
# @return [json] Returns the updated connection. | ||
def update_connection(connection_id, body) | ||
fail Auth0::MissingConnectionId, 'you must specify a connection id' if connection_id.to_s.empty? | ||
fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This format does not match on all validations for the rest of the endpoints. What form should we use: "you must..." or "Must..."? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of the errors are 'Must....;, so we'll keep this one, but we should change it in clients.rb There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
path = "/api/v2/connections/#{connection_id}" | ||
patch(path, body) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 'Must...' and all the message in this class too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, we should also update the tests.