|
# encoding: utf-8 |
|
|
|
# |
|
# WARNING: Do not edit by hand, this file was generated by Heroics: |
|
# |
|
# https://github.com/interagent/heroics |
|
# |
|
|
|
require 'heroics' |
|
require 'uri' |
|
|
|
module Amino |
|
# Get a Client configured to use HTTP Basic authentication. |
|
# |
|
# @param api_key [String] The API key to use when connecting. |
|
# @param options [Hash<Symbol,String>] Optionally, custom settings |
|
# to use with the client. Allowed options are `default_headers`, |
|
# `cache`, `user` and `url`. |
|
# @return [Client] A client configured to use the API with HTTP Basic |
|
# authentication. |
|
def self.connect(api_key, options=nil) |
|
options = custom_options(options) |
|
uri = URI.parse(options[:url]) |
|
uri.user = URI.encode_www_form_component options.fetch(:user, 'user') |
|
uri.password = api_key |
|
client = Heroics.client_from_schema(SCHEMA, uri.to_s, options) |
|
Client.new(client) |
|
end |
|
|
|
# Get a Client configured to use OAuth authentication. |
|
# |
|
# @param oauth_token [String] The OAuth token to use with the API. |
|
# @param options [Hash<Symbol,String>] Optionally, custom settings |
|
# to use with the client. Allowed options are `default_headers`, |
|
# `cache` and `url`. |
|
# @return [Client] A client configured to use the API with OAuth |
|
# authentication. |
|
def self.connect_oauth(oauth_token, options=nil) |
|
options = custom_options(options) |
|
url = options[:url] |
|
client = Heroics.oauth_client_from_schema(oauth_token, SCHEMA, url, options) |
|
Client.new(client) |
|
end |
|
|
|
# Get a Client configured to use Token authentication. |
|
# |
|
# @param token [String] The token to use with the API. |
|
# @param options [Hash<Symbol,String>] Optionally, custom settings |
|
# to use with the client. Allowed options are `default_headers`, |
|
# `cache` and `url`. |
|
# @return [Client] A client configured to use the API with OAuth |
|
# authentication. |
|
def self.connect_token(token, options=nil) |
|
options = custom_options(options) |
|
url = options[:url] |
|
client = Heroics.token_client_from_schema(token, SCHEMA, url, options) |
|
Client.new(client) |
|
end |
|
|
|
# Get customized options. |
|
def self.custom_options(options) |
|
return default_options if options.nil? |
|
|
|
final_options = default_options |
|
if options[:default_headers] |
|
final_options[:default_headers].merge!(options[:default_headers]) |
|
end |
|
final_options[:cache] = options[:cache] if options[:cache] |
|
final_options[:url] = options[:url] if options[:url] |
|
final_options[:user] = options[:user] if options[:user] |
|
final_options |
|
end |
|
|
|
# Get the default options. |
|
def self.default_options |
|
default_headers = {} |
|
cache = Moneta.new(:Memory) |
|
{ |
|
default_headers: default_headers, |
|
cache: cache, |
|
url: "https://amino-production.herokuapp.com" |
|
} |
|
end |
|
|
|
private_class_method :default_options, :custom_options |
|
|
|
# AMI Build service |
|
class Client |
|
def initialize(client) |
|
@client = client |
|
end |
|
|
|
# AWS Account management for sharing build artifacts |
|
# |
|
# @return [AwsAccount] |
|
def aws_account |
|
@aws_account_resource ||= AwsAccount.new(@client) |
|
end |
|
|
|
# Build artifact |
|
# |
|
# @return [Build] |
|
def build |
|
@build_resource ||= Build.new(@client) |
|
end |
|
|
|
# Build Profile |
|
# |
|
# @return [Profile] |
|
def profile |
|
@profile_resource ||= Profile.new(@client) |
|
end |
|
end |
|
|
|
private |
|
|
|
# AWS Account management for sharing build artifacts |
|
class AwsAccount |
|
def initialize(client) |
|
@client = client |
|
end |
|
|
|
# Register a new aws-account. |
|
# |
|
# @param body: the object to pass as the request payload |
|
def create(body) |
|
@client.aws_account.create(body) |
|
end |
|
|
|
# Delete an existing aws-account. |
|
# |
|
# @param aws_account_id_or_aws_account_aws_account_id: unique identifier of aws-account or AWS Account ID |
|
def delete(aws_account_id_or_aws_account_aws_account_id) |
|
@client.aws_account.delete(aws_account_id_or_aws_account_aws_account_id) |
|
end |
|
|
|
# Info for existing aws-account. |
|
# |
|
# @param aws_account_id_or_aws_account_aws_account_id: unique identifier of aws-account or AWS Account ID |
|
def info(aws_account_id_or_aws_account_aws_account_id) |
|
@client.aws_account.info(aws_account_id_or_aws_account_aws_account_id) |
|
end |
|
|
|
# List registered aws-accounts. |
|
def list() |
|
@client.aws_account.list() |
|
end |
|
end |
|
|
|
# Build artifact |
|
class Build |
|
def initialize(client) |
|
@client = client |
|
end |
|
|
|
# Create a new build. |
|
# |
|
# @param body: the object to pass as the request payload |
|
def create(body) |
|
@client.build.create(body) |
|
end |
|
|
|
# Create or Get Build with a known ID. |
|
# |
|
# @param build_identity: |
|
# @param body: the object to pass as the request payload |
|
def get_or_create(build_identity, body) |
|
@client.build.get_or_create(build_identity, body) |
|
end |
|
|
|
# Delete an existing build. |
|
# |
|
# @param build_identity: |
|
def delete(build_identity) |
|
@client.build.delete(build_identity) |
|
end |
|
|
|
# Info for existing build. |
|
# |
|
# @param build_identity: |
|
def info(build_identity) |
|
@client.build.info(build_identity) |
|
end |
|
|
|
# Get log for existing build. |
|
# |
|
# @param build_identity: |
|
def log(build_identity) |
|
@client.build.log(build_identity) |
|
end |
|
|
|
# List existing builds. |
|
def list() |
|
@client.build.list() |
|
end |
|
end |
|
|
|
# Build Profile |
|
class Profile |
|
def initialize(client) |
|
@client = client |
|
end |
|
|
|
# List existing profiles. |
|
def list() |
|
@client.profile.list() |
|
end |
|
|
|
# Create a new profile. |
|
# |
|
# @param body: the object to pass as the request payload |
|
def create(body) |
|
@client.profile.create(body) |
|
end |
|
|
|
# Delete an existing profile. |
|
# |
|
# @param profile_identity: |
|
def delete(profile_identity) |
|
@client.profile.delete(profile_identity) |
|
end |
|
|
|
# Info for existing profile. |
|
# |
|
# @param profile_identity: |
|
def info(profile_identity) |
|
@client.profile.info(profile_identity) |
|
end |
|
|
|
# Update an existing profile. |
|
# |
|
# @param profile_identity: |
|
# @param body: the object to pass as the request payload |
|
def update(profile_identity, body) |
|
@client.profile.update(profile_identity, body) |
|
end |
|
end |
|
|
|
SCHEMA = Heroics::Schema.new(MultiJson.load(<<-'HEROICS_SCHEMA')) |
|
{ |
|
"$schema":"http://json-schema.org/draft-04/hyper-schema", |
|
"definitions":{ |
|
"aws-account":{ |
|
"$schema":"http://json-schema.org/draft-04/hyper-schema", |
|
"title":"AWS Accounts", |
|
"description":"AWS Account management for sharing build artifacts", |
|
"definitions":{ |
|
"id":{ |
|
"description":"unique identifier of aws-account", |
|
"example":"01234567-89ab-cdef-0123-456789abcdef", |
|
"format":"uuid", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"identity":{ |
|
"$ref":"#/definitions/aws-account/definitions/id" |
|
}, |
|
"flexible_identity":{ |
|
"description":"identifier using either the uuid or the aws_account_id", |
|
"anyOf":[ |
|
{ |
|
"$ref":"#/definitions/aws-account/definitions/id" |
|
}, |
|
{ |
|
"$ref":"#/definitions/aws-account/definitions/aws_account_id" |
|
} |
|
] |
|
}, |
|
"aws_account_id":{ |
|
"description":"AWS Account ID", |
|
"example":"01234567890", |
|
"pattern":"\\A[0-9]+\\Z", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"created_at":{ |
|
"description":"when aws-account was created", |
|
"example":"2012-01-01T12:00:00Z", |
|
"format":"date-time", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"updated_at":{ |
|
"description":"when aws-account was updated", |
|
"example":"2012-01-01T12:00:00Z", |
|
"format":"date-time", |
|
"type":[ |
|
"string", |
|
"null" |
|
] |
|
} |
|
}, |
|
"links":[ |
|
{ |
|
"description":"Register a new aws-account.", |
|
"href":"/aws-accounts", |
|
"method":"POST", |
|
"rel":"create", |
|
"schema":{ |
|
"properties":{ |
|
"aws_account_id":{ |
|
"$ref":"#/definitions/aws-account/definitions/aws_account_id" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
], |
|
"required":[ |
|
"aws_account_id" |
|
] |
|
}, |
|
"title":"Create" |
|
}, |
|
{ |
|
"description":"Delete an existing aws-account.", |
|
"href":"/aws-accounts/{(%23%2Fdefinitions%2Faws-account%2Fdefinitions%2Fflexible_identity)}", |
|
"method":"DELETE", |
|
"rel":"destroy", |
|
"title":"Delete" |
|
}, |
|
{ |
|
"description":"Info for existing aws-account.", |
|
"href":"/aws-accounts/{(%23%2Fdefinitions%2Faws-account%2Fdefinitions%2Fflexible_identity)}", |
|
"method":"GET", |
|
"rel":"self", |
|
"title":"Info" |
|
}, |
|
{ |
|
"description":"List registered aws-accounts.", |
|
"href":"/aws-accounts", |
|
"method":"GET", |
|
"rel":"instances", |
|
"title":"List" |
|
} |
|
], |
|
"properties":{ |
|
"id":{ |
|
"$ref":"#/definitions/aws-account/definitions/id" |
|
}, |
|
"aws_account_id":{ |
|
"$ref":"#/definitions/aws-account/definitions/aws_account_id" |
|
}, |
|
"created_at":{ |
|
"$ref":"#/definitions/aws-account/definitions/created_at" |
|
}, |
|
"updated_at":{ |
|
"$ref":"#/definitions/aws-account/definitions/updated_at" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
] |
|
}, |
|
"build":{ |
|
"$schema":"http://json-schema.org/draft-04/hyper-schema", |
|
"title":"Build", |
|
"description":"Build artifact", |
|
"definitions":{ |
|
"identity":{ |
|
"$ref":"#/definitions/build/definitions/id" |
|
}, |
|
"id":{ |
|
"description":"unique identifier of build", |
|
"example":"01234567-89ab-cdef-0123-456789abcdef", |
|
"format":"uuid", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"created_at":{ |
|
"description":"when build was created", |
|
"example":"2012-01-01T12:00:00Z", |
|
"format":"date-time", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"updated_at":{ |
|
"description":"when build was updated", |
|
"example":"2012-01-01T12:00:00Z", |
|
"format":"date-time", |
|
"type":[ |
|
"string", |
|
"null" |
|
] |
|
}, |
|
"ami_id":{ |
|
"description":"AWS Image ID", |
|
"example":"ami-a3e2c3d4", |
|
"type":[ |
|
"string", |
|
"null" |
|
], |
|
"readOnly":true |
|
}, |
|
"state":{ |
|
"description":"state of the build", |
|
"example":"succeeded", |
|
"type":[ |
|
"string" |
|
], |
|
"enum":[ |
|
"new", |
|
"building", |
|
"sharing", |
|
"failed", |
|
"succeeded" |
|
], |
|
"readOnly":true |
|
}, |
|
"config":{ |
|
"description":"config overrides for the build", |
|
"example":{}, |
|
"type":[ |
|
"object" |
|
] |
|
} |
|
}, |
|
"links":[ |
|
{ |
|
"description":"Create a new build.", |
|
"href":"/builds", |
|
"method":"POST", |
|
"rel":"create", |
|
"schema":{ |
|
"properties":{ |
|
"profile":{ |
|
"anyOf":[ |
|
{ |
|
"$ref":"#/definitions/profile/definitions/id" |
|
}, |
|
{ |
|
"$ref":"#/definitions/profile/definitions/name" |
|
} |
|
] |
|
}, |
|
"config":{ |
|
"$ref":"#/definitions/build/definitions/config" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
], |
|
"required":[ |
|
"profile" |
|
] |
|
}, |
|
"title":"Create" |
|
}, |
|
{ |
|
"description":"Create or Get Build with a known ID.", |
|
"title":"Get or Create", |
|
"href":"/builds/{(%23%2Fdefinitions%2Fbuild%2Fdefinitions%2Fidentity)}", |
|
"method":"PUT", |
|
"rel":"create", |
|
"schema":{ |
|
"properties":{ |
|
"profile":{ |
|
"anyOf":[ |
|
{ |
|
"$ref":"#/definitions/profile/definitions/id" |
|
}, |
|
{ |
|
"$ref":"#/definitions/profile/definitions/name" |
|
} |
|
] |
|
}, |
|
"config":{ |
|
"$ref":"#/definitions/build/definitions/config" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
], |
|
"required":[ |
|
"profile" |
|
] |
|
} |
|
}, |
|
{ |
|
"description":"Delete an existing build.", |
|
"href":"/builds/{(%23%2Fdefinitions%2Fbuild%2Fdefinitions%2Fidentity)}", |
|
"method":"DELETE", |
|
"rel":"destroy", |
|
"title":"Delete" |
|
}, |
|
{ |
|
"description":"Info for existing build.", |
|
"href":"/builds/{(%23%2Fdefinitions%2Fbuild%2Fdefinitions%2Fidentity)}", |
|
"method":"GET", |
|
"rel":"self", |
|
"title":"Info" |
|
}, |
|
{ |
|
"description":"Get log for existing build.", |
|
"href":"/builds/{(%23%2Fdefinitions%2Fbuild%2Fdefinitions%2Fidentity)}/log", |
|
"method":"GET", |
|
"rel":"log", |
|
"title":"Log", |
|
"mediaType":"text/plain" |
|
}, |
|
{ |
|
"description":"List existing builds.", |
|
"href":"/builds", |
|
"method":"GET", |
|
"rel":"instances", |
|
"title":"List" |
|
} |
|
], |
|
"properties":{ |
|
"id":{ |
|
"$ref":"#/definitions/build/definitions/id" |
|
}, |
|
"state":{ |
|
"$ref":"#/definitions/build/definitions/state" |
|
}, |
|
"ami_id":{ |
|
"$ref":"#/definitions/build/definitions/ami_id" |
|
}, |
|
"profile":{ |
|
"$ref":"#/definitions/profile" |
|
}, |
|
"created_at":{ |
|
"$ref":"#/definitions/build/definitions/created_at" |
|
}, |
|
"updated_at":{ |
|
"$ref":"#/definitions/build/definitions/updated_at" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
] |
|
}, |
|
"profile":{ |
|
"$schema":"http://json-schema.org/draft-04/hyper-schema", |
|
"title":"Build Profile", |
|
"description":"Build Profile", |
|
"definitions":{ |
|
"id":{ |
|
"description":"unique identifier of the profile", |
|
"example":"01234567-89ab-cdef-0123-456789abcdef", |
|
"format":"uuid", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"identity":{ |
|
"$ref":"#/definitions/profile/definitions/id" |
|
}, |
|
"name":{ |
|
"description":"common name of the profile", |
|
"example":"dogwood-control", |
|
"pattern":"\\A[a-z-]+\\Z", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"created_at":{ |
|
"description":"when profile was created", |
|
"example":"2012-01-01T12:00:00Z", |
|
"format":"date-time", |
|
"type":[ |
|
"string" |
|
] |
|
}, |
|
"updated_at":{ |
|
"description":"when profile was updated", |
|
"example":"2012-01-01T12:00:00Z", |
|
"format":"date-time", |
|
"type":[ |
|
"string", |
|
"null" |
|
] |
|
}, |
|
"ansible_repo":{ |
|
"description":"git repository that contains the profiles playbooks", |
|
"example":"https://username:password@github.com/example/ansible.git", |
|
"format":"uri", |
|
"type":[ |
|
"string", |
|
"null" |
|
] |
|
} |
|
}, |
|
"links":[ |
|
{ |
|
"description":"List existing profiles.", |
|
"href":"/profiles", |
|
"method":"GET", |
|
"rel":"instances", |
|
"title":"List" |
|
}, |
|
{ |
|
"description":"Create a new profile.", |
|
"href":"/profiles", |
|
"method":"POST", |
|
"rel":"create", |
|
"schema":{ |
|
"properties":{ |
|
"name":{ |
|
"$ref":"#/definitions/profile/definitions/name" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
], |
|
"required":[ |
|
"name" |
|
] |
|
}, |
|
"title":"Create" |
|
}, |
|
{ |
|
"description":"Delete an existing profile.", |
|
"href":"/profiles/{(%23%2Fdefinitions%2Fprofile%2Fdefinitions%2Fidentity)}", |
|
"method":"DELETE", |
|
"rel":"destroy", |
|
"title":"Delete" |
|
}, |
|
{ |
|
"description":"Info for existing profile.", |
|
"href":"/profiles/{(%23%2Fdefinitions%2Fprofile%2Fdefinitions%2Fidentity)}", |
|
"method":"GET", |
|
"rel":"self", |
|
"title":"Info" |
|
}, |
|
{ |
|
"description":"List existing profiles.", |
|
"href":"/profiles", |
|
"method":"GET", |
|
"rel":"instances", |
|
"title":"List" |
|
}, |
|
{ |
|
"description":"Update an existing profile.", |
|
"href":"/profiles/{(%23%2Fdefinitions%2Fprofile%2Fdefinitions%2Fidentity)}", |
|
"method":"PATCH", |
|
"rel":"update", |
|
"schema":{ |
|
"properties":{ |
|
"name":{ |
|
"$ref":"#/definitions/profile/definitions/name" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
] |
|
}, |
|
"title":"Update" |
|
} |
|
], |
|
"properties":{ |
|
"created_at":{ |
|
"$ref":"#/definitions/profile/definitions/created_at" |
|
}, |
|
"id":{ |
|
"$ref":"#/definitions/profile/definitions/id" |
|
}, |
|
"name":{ |
|
"$ref":"#/definitions/profile/definitions/name" |
|
}, |
|
"updated_at":{ |
|
"$ref":"#/definitions/profile/definitions/updated_at" |
|
}, |
|
"ansible_repo":{ |
|
"$ref":"#/definitions/profile/definitions/ansible_repo" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
] |
|
} |
|
}, |
|
"properties":{ |
|
"aws-account":{ |
|
"$ref":"#/definitions/aws-account" |
|
}, |
|
"build":{ |
|
"$ref":"#/definitions/build" |
|
}, |
|
"profile":{ |
|
"$ref":"#/definitions/profile" |
|
} |
|
}, |
|
"type":[ |
|
"object" |
|
], |
|
"title":"Amino", |
|
"description":"AMI Build service", |
|
"id":"api-amino", |
|
"links":[ |
|
{ |
|
"href":"https://api.example.com", |
|
"rel":"self" |
|
} |
|
] |
|
} |
|
|
|
HEROICS_SCHEMA |
|
end |