algosec-sdk 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9084c00c73ae8f10e2b6f76d51a28b37ad4bf427
4
- data.tar.gz: 55a2673e55f1fce9f55dd54c31ac388871911aab
3
+ metadata.gz: d57a7f42feec59ab1260d8b662d201048b341515
4
+ data.tar.gz: f116ced6c0739e3823ced4f4e10b82219131025b
5
5
  SHA512:
6
- metadata.gz: ba8ea7d72dde6fddba0c5f93dbe318ede6d0a0ae53903bee470cb8fa23246fbb46ecd86616da873ccbadbf95277138adfc90eef5f5c6a173074dbc3e6de13398
7
- data.tar.gz: 565c39137f6f8d2c9a24e3e82889899dfa7778b6726494359b1ecb1f127eb7489cebc35d630abfb9cf67a07515fb0b5241a7bb2536969971b112989eaa5ee558
6
+ metadata.gz: 982599fbbf3ac54e546469470dac5d86d6456dddfd1669032b10df17e290759f51c46afe5a7e01b964aaae5de343bb966cc35db939ceb625d31503f212ae4a55
7
+ data.tar.gz: b8a0bd17374d44d8d642bc3b9a3bd7b13fd2d9f2d8e24d21e6cd39ccb0a2bfa11bd3ea61457c0ba1ae142b1e7c6a80e99feafda1f1e235fca7203ab40668044d
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.1.0
2
+ current_version = 1.2.0
3
3
  commit = True
4
4
  tag = True
5
5
 
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # See default at https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
2
  AllCops:
3
- TargetRubyVersion: 2.1
3
+ TargetRubyVersion: 2.2
4
4
 
5
5
  Metrics/ClassLength:
6
6
  Max: 200
@@ -9,7 +9,7 @@ Metrics/LineLength:
9
9
  Max: 120
10
10
 
11
11
  Metrics/ModuleLength:
12
- Max: 200
12
+ Max: 220
13
13
 
14
14
  Metrics/ParameterLists:
15
15
  Max: 6
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  language: ruby
2
2
  notifications:
3
- - false
3
+ email:
4
+ on_success: never
5
+ on_failure: always
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
3
5
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  require 'bundler/gem_tasks'
3
5
  require 'bundler/setup'
data/algosec-sdk.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # http://guides.rubygems.org/specification-reference
2
4
  require_relative './lib/algosec-sdk/version'
3
5
 
@@ -23,6 +25,6 @@ Gem::Specification.new do |spec|
23
25
  spec.add_development_dependency 'pry'
24
26
  spec.add_development_dependency 'rake'
25
27
  spec.add_development_dependency 'rspec'
26
- spec.add_development_dependency 'rubocop', '> 0.49.0'
28
+ spec.add_development_dependency 'rubocop', '~> 0.58.2'
27
29
  spec.add_development_dependency 'simplecov'
28
30
  end
data/lib/algosec-sdk.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'algosec-sdk/version'
2
4
  require_relative 'algosec-sdk/client'
3
5
  require_relative 'algosec-sdk/exceptions'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
  require_relative 'rest'
3
5
  # Load all helpers:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # (c) Copyright 2018 AlgoSec Systems
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'flow_comparisons'
2
4
  require 'set'
3
5
  require 'ipaddress'
@@ -30,6 +32,41 @@ module ALGOSEC_SDK
30
32
  response_handler(rest_post('/BusinessFlow/rest/v1/login'))
31
33
  end
32
34
 
35
+ # Create an application
36
+ # @param [String] name The application's name.
37
+ # @param [Array<String>] custom_fields Existing custom fields to assign to the application.
38
+ # @param [Array<String>] contacts Existing contacts to assign to the application.
39
+ # @param [Array<String>] labels Existing labels to assign to the application.
40
+ # @param [Array<String>] flows The flows to add to the application upon creation.
41
+ # @raise [RuntimeError] if the request failed
42
+ # @return Newly created Application object
43
+ def create_application(
44
+ name,
45
+ custom_fields = [],
46
+ contacts = [],
47
+ labels = [],
48
+ flows = []
49
+ )
50
+ new_application = {
51
+ name: name,
52
+ custom_fields: custom_fields,
53
+ contacts: contacts,
54
+ labels: labels,
55
+ flows: flows
56
+ }
57
+ response = rest_post('/BusinessFlow/rest/v1/applications/new', body: new_application)
58
+ response_handler(response)
59
+ end
60
+
61
+ # Decommission an application
62
+ # @param [String] app_revision_id
63
+ # @raise [RuntimeError] if the request failed
64
+ # @return true
65
+ def decommission_application(app_revision_id)
66
+ response = rest_post("/BusinessFlow/rest/v1/applications/#{app_revision_id}/decommission")
67
+ response_handler(response)
68
+ end
69
+
33
70
  # Get list of application flows for an application revision id
34
71
  # @param [String, Symbol] app_revision_id
35
72
  # @raise [RuntimeError] if the request failed
@@ -138,14 +175,37 @@ module ALGOSEC_SDK
138
175
  requested_flow
139
176
  end
140
177
 
178
+ # Get all applications
179
+ # @raise [RuntimeError] if the request failed
180
+ # @return [Array<Hash>] application objects
181
+ def get_applications
182
+ response = rest_get('/BusinessFlow/rest/v1/applications/')
183
+ response_handler(response)
184
+ end
185
+
186
+ # Get application by name
187
+ # @param [String, Symbol] app_name
188
+ # @raise [RuntimeError] if the request failed
189
+ # @return [Hash] application object
190
+ def get_application_by_name(app_name)
191
+ response = rest_get("/BusinessFlow/rest/v1/applications/name/#{app_name}")
192
+ response_handler(response)
193
+ end
194
+
141
195
  # Get latest application revision id by application name
142
196
  # @param [String, Symbol] app_name
143
197
  # @raise [RuntimeError] if the request failed
144
198
  # @return [Boolean] application revision id
145
199
  def get_app_revision_id_by_name(app_name)
146
- response = rest_get("/BusinessFlow/rest/v1/applications/name/#{app_name}")
147
- app = response_handler(response)
148
- app['revisionID']
200
+ get_application_by_name(app_name)['revisionID']
201
+ end
202
+
203
+ # Get application id by it's name
204
+ # @param [String, Symbol] app_name
205
+ # @raise [RuntimeError] if the request failed
206
+ # @return [Boolean] application id
207
+ def get_app_id_by_name(app_name)
208
+ get_application_by_name(app_name)['applicationId']
149
209
  end
150
210
 
151
211
  # Apply application draft
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module ALGOSEC_SDK
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
  require 'net/http'
3
5
  require 'openssl'
@@ -57,7 +59,6 @@ module ALGOSEC_SDK
57
59
  rescue SocketError => e
58
60
  msg = "Failed to connect to AlgoSec host #{@host}!\n"
59
61
  @logger.error msg
60
- e.message.prepend(msg)
61
62
  raise e
62
63
  end
63
64
 
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Gem version defined here
2
4
  module ALGOSEC_SDK
3
- VERSION = '1.1.0'.freeze
5
+ VERSION = '1.2.0'.freeze
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  desc 'Test API SDK end-to-end against an AlgoSec machine'
2
4
  task :e2e, %i[app host user password] => [] do |_t, args|
3
5
  require 'algosec-sdk'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algosec-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Almog Cohen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">"
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.49.0
103
+ version: 0.58.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">"
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.49.0
110
+ version: 0.58.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement