mio-config 2.10.0 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mio/client.rb +12 -0
- data/lib/mio/errors.rb +2 -0
- data/lib/mio/model.rb +4 -3
- data/lib/mio/model/autoload.rb +4 -0
- data/lib/mio/model/email_message_action.rb +5 -12
- data/lib/mio/model/import_action.rb +5 -12
- data/lib/mio/model/launch_workflow_action.rb +36 -0
- data/lib/mio/model/launchworkflow/launch_workflow.rb +32 -0
- data/lib/mio/model/launchworkflow/workflow_variable.rb +58 -0
- data/lib/mio/model/message_template.rb +1 -1
- data/lib/mio/model/metadatadefinition/definition.rb +2 -2
- data/lib/mio/model/place_holder_group_asset_action.rb +5 -12
- data/lib/mio/model/variant.rb +6 -12
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fdb93a6563908c0714373acc4eb3bb028de7266
|
4
|
+
data.tar.gz: de125590f391106cdb7385da4f0515c50ea38cab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f087130190f9791497ef9a1cb41d73f1373d5ecfc80abd447231226eaf93ee69b0fe99d1cbfa8d106ad984880120872296250ecc72132381f94919a02e679a3
|
7
|
+
data.tar.gz: 0c3084fa2ad9a61955c09a8ed43fe2ded2a25471019b275eaf091700ab488dcb4534039aa762d48da647fd4d52fa6b08acabb4619b254ca66f90043d252808e9
|
data/lib/mio/client.rb
CHANGED
@@ -19,6 +19,18 @@ class Mio
|
|
19
19
|
@agent.basic_auth(username, password)
|
20
20
|
end
|
21
21
|
|
22
|
+
def find resource, id, opts={}, accept='application/json'
|
23
|
+
url = path resource, id
|
24
|
+
response = get url, opts, accept
|
25
|
+
unless response.success? || response.status == 404
|
26
|
+
raise Mio::Client::LoadOfBollocks, "GET on #{url}, returned #{response.status}"
|
27
|
+
end
|
28
|
+
|
29
|
+
h = make_object response.body
|
30
|
+
h[:status] = response.status
|
31
|
+
h
|
32
|
+
end
|
33
|
+
|
22
34
|
def find_all resource, opts={}, accept='application/json'
|
23
35
|
url = path(resource)
|
24
36
|
response = get url, opts, accept
|
data/lib/mio/errors.rb
CHANGED
@@ -10,6 +10,8 @@ class Mio
|
|
10
10
|
class DataValueError < ArgumentError ; end
|
11
11
|
class NoSuchResource < ArgumentError ; end
|
12
12
|
class EmptyField < ArgumentError ; end
|
13
|
+
class DateVariableInvalid < ArgumentError ; end
|
14
|
+
class ObjectVariableInvalid < ArgumentError ; end
|
13
15
|
end
|
14
16
|
|
15
17
|
class Config
|
data/lib/mio/model.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Mio
|
2
2
|
class Model
|
3
|
-
attr_reader :args
|
3
|
+
attr_reader :args, :search, :client
|
4
4
|
class << self
|
5
5
|
attr_accessor :fields, :resource_name
|
6
6
|
def set_resource r
|
@@ -97,7 +97,7 @@ class Mio
|
|
97
97
|
alias_method :start!, :set_start
|
98
98
|
|
99
99
|
def validate
|
100
|
-
testable =
|
100
|
+
testable = self.args.dup.to_h
|
101
101
|
|
102
102
|
self.class.fields.each do |f|
|
103
103
|
unless testable.key? f[:name]
|
@@ -109,7 +109,8 @@ class Mio
|
|
109
109
|
raise Mio::Model::DataTypeError, "#{f[:name]} should be of type #{f[:type]} for #{self}"
|
110
110
|
end
|
111
111
|
|
112
|
-
unless f[
|
112
|
+
#unless f[:matcher].nil? or extracted_field.to_s.match(f[:matcher])
|
113
|
+
if !f[:matcher].nil? && extracted_field.to_s.match(f[:matcher]).nil?
|
113
114
|
raise Mio::Model::DataValueError, "#{self} #{f[:name]} value '#{extracted_field}' does not match #{f[:matcher]}"
|
114
115
|
end
|
115
116
|
end
|
data/lib/mio/model/autoload.rb
CHANGED
@@ -8,4 +8,8 @@ end
|
|
8
8
|
|
9
9
|
Dir[File.join(File.dirname(__FILE__), 'metadatadefinition', '*.rb')].each do |file|
|
10
10
|
require File.join('mio', 'model', 'metadatadefinition', File.basename(file, File.extname(file)))
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'launchworkflow', '*.rb')].each do |file|
|
14
|
+
require File.join('mio', 'model', 'launchworkflow', File.basename(file, File.extname(file)))
|
11
15
|
end
|
@@ -21,20 +21,13 @@ class Mio
|
|
21
21
|
}
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
md = message_templates[r].find{|md| md['name'] == mesage_template_name}
|
29
|
-
if md.nil?
|
30
|
-
raise Mio::Model::NoSuchResource, 'No such message template [' + mesage_template_name + ']'
|
24
|
+
def config_hash
|
25
|
+
template = @search.find_messageTemplates_by_name(@args.template).first
|
26
|
+
if template.nil?
|
27
|
+
raise Mio::Model::NoSuchResource, 'No such template [' + @args.template + ']'
|
31
28
|
end
|
32
29
|
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def config_hash
|
37
|
-
{ 'message-template': { id: get_message_template_id(@args.template) },
|
30
|
+
{ 'message-template': { id: template['id'] },
|
38
31
|
recipients: { expression: [ { value: @args.recipientExpression, isExpression: false } ] }
|
39
32
|
}
|
40
33
|
end
|
@@ -24,19 +24,12 @@ class Mio
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
md = metadata_definitions[r].find{|md| md['name'] == metadata_definition_name}
|
32
|
-
if md.nil?
|
33
|
-
raise Mio::Model::NoSuchResource, 'No such metadata definition[' + metadata_definition_name + ']'
|
27
|
+
def config_hash
|
28
|
+
metadata_definition = @search.find_metadataDefinitions_by_name(@args.metadataDefinition).first
|
29
|
+
if metadata_definition.nil?
|
30
|
+
raise Mio::Model::NoSuchResource, 'No such metadata definition [' + @args.metadataDefinition + ']'
|
34
31
|
end
|
35
32
|
|
36
|
-
md['id']
|
37
|
-
end
|
38
|
-
|
39
|
-
def config_hash
|
40
33
|
{
|
41
34
|
"source-file": {
|
42
35
|
"source": {
|
@@ -84,7 +77,7 @@ class Mio
|
|
84
77
|
},
|
85
78
|
"metadata": {
|
86
79
|
"metadata-definition": {
|
87
|
-
"id":
|
80
|
+
"id": metadata_definition['id']
|
88
81
|
},
|
89
82
|
"source-json-variable": {
|
90
83
|
"value": @args.sourceJsonVariable,
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Mio
|
2
|
+
class Model
|
3
|
+
class LaunchWorkflowAction < Model
|
4
|
+
set_resource :actions
|
5
|
+
|
6
|
+
field :name, String, 'Name of the Import Action'
|
7
|
+
field :visibility, Array, 'Ids of the accounts which may see the import action', [4]
|
8
|
+
field :workflows, Array, 'Array of Launch Workflow configuration'
|
9
|
+
field :enable, Symbol, ':true or :false', :true
|
10
|
+
field :start, Symbol, ':true or :false', :true
|
11
|
+
|
12
|
+
def create_hash
|
13
|
+
plugin = 'tv.nativ.mio.enterprise.execution.action.file.impl.launch.DefaultLaunchWorkflowCommand'
|
14
|
+
{name: @args.name,
|
15
|
+
pluginClass: plugin,
|
16
|
+
visibilityIds: @args.visibility,
|
17
|
+
'type': 'launch',
|
18
|
+
'runRuleExpression': ''
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_hash
|
23
|
+
{workflows: @args.workflows
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def validate
|
28
|
+
super
|
29
|
+
if @args.workflows.empty?
|
30
|
+
raise Mio::Model::EmptyField, 'Field workflows to Mio::Model::LaunchWorkflowAction must contain at least one launch workflow'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Mio
|
2
|
+
class Model
|
3
|
+
class LaunchWorkflowAction
|
4
|
+
class LaunchWorkflow < Model
|
5
|
+
set_resource :actions
|
6
|
+
|
7
|
+
field :name, String, 'Name of the workflow to launch'
|
8
|
+
field :inheritVariables, Symbol, 'Inherit variables from calling workflow'
|
9
|
+
field :workFlowStringVariables, Array, ''
|
10
|
+
field :workFlowObjectVariables, Array, ''
|
11
|
+
field :workflowDateVariables, Array, ''
|
12
|
+
|
13
|
+
nested true
|
14
|
+
|
15
|
+
def create_hash
|
16
|
+
workflow_definition = @search.find_workflowDefinitions_by_name(@args.name).first
|
17
|
+
if workflow_definition.nil?
|
18
|
+
raise Mio::Model::NoSuchResource, 'No such workflowDefinition [' + @args.name + ']'
|
19
|
+
end
|
20
|
+
|
21
|
+
{Workflow: { id: workflow_definition['id']},
|
22
|
+
'inherit-variables': @args.inheritVariables,
|
23
|
+
'workflow-string-variable': @args.workFlowStringVariables,
|
24
|
+
'workflow-object-variable': @args.workFlowObjectVariables,
|
25
|
+
'workflow-date-variable': @args.workflowDateVariables
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class Mio
|
2
|
+
class Model
|
3
|
+
class LaunchWorkflowAction
|
4
|
+
class WorkflowVariable < Model
|
5
|
+
set_resource :actions
|
6
|
+
|
7
|
+
field :key, String, 'Variable key'
|
8
|
+
field :value, String, 'Variable value if type==date must be dd-MM-yy HH:mm:ss, if type==object must be numeric and exist as an asset'
|
9
|
+
field :type, String, 'Key type or prefix', nil, /^(string|date|object)$/
|
10
|
+
|
11
|
+
nested true
|
12
|
+
|
13
|
+
def create_hash
|
14
|
+
{@args.type+'-variable-key' => {value: @args.key, isExpression: false},
|
15
|
+
@args.type+'-variable-value' => {value: @args.value, isExpression: false}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_date_value
|
20
|
+
# Ensure value conforms to dd-MM-yyyy HH:mm:ss
|
21
|
+
unless @args.value =~ /^(?:0?[1-9]|[1-2]\d|3[01])-(?:0?[1-9]|1[0-2])-\d{4}\s([0]?\d|1\d|2[0-3]):([0-5]\d):([0-5]\d)$/
|
22
|
+
raise Mio::Model::DateVariableInvalid, 'Workflow variable of type date must conform to dd-MM-yy HH:mm:ss [' + @args.value + ']'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def asset_by_id
|
27
|
+
asset = @client.find 'assets', @args.value
|
28
|
+
|
29
|
+
if asset[:status] == 404
|
30
|
+
raise Mio::Model::NoSuchResource, 'No such asset [' + @args.value + ']'
|
31
|
+
end
|
32
|
+
@args.value
|
33
|
+
end
|
34
|
+
|
35
|
+
def validate_object_value
|
36
|
+
unless @args.value =~ /^[0-9]*$/
|
37
|
+
raise Mio::Model::ObjectVariableInvalid, 'Workflow variable of type object must be a number [' + @args.value + ']'
|
38
|
+
end
|
39
|
+
asset_by_id
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate
|
43
|
+
super
|
44
|
+
if @args.type == 'date'
|
45
|
+
validate_date_value
|
46
|
+
end
|
47
|
+
if @args.type == 'object'
|
48
|
+
validate_object_value
|
49
|
+
end
|
50
|
+
|
51
|
+
true
|
52
|
+
end
|
53
|
+
alias_method :valid?, :validate
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -6,7 +6,7 @@ class Mio
|
|
6
6
|
field :name, String, 'Name of the Email Message Action'
|
7
7
|
field :visibility, Array, 'Ids of the accounts which may see the import action', [4]
|
8
8
|
field :subject, String, 'Subject of email'
|
9
|
-
field :priority, String, 'Email Priority - Highest, High, Normal, Low, Lowest', 'Normal'
|
9
|
+
field :priority, String, 'Email Priority - Highest, High, Normal, Low, Lowest', 'Normal', /^(Highest|High|Normal|Low|Lowest)$/
|
10
10
|
field :template, String, 'Email template HTML'
|
11
11
|
|
12
12
|
field :enable, Symbol, ':true or :false', :true
|
@@ -6,12 +6,12 @@ class Mio
|
|
6
6
|
|
7
7
|
field :name, String, 'Metadata Definition Name'
|
8
8
|
field :displayName, String, 'Display name'
|
9
|
-
field :type, String, 'Metdata type
|
9
|
+
field :type, String, 'Metdata type tsingle-option|text|url|boolean|image', 'text', /^(single-option|text|url|boolean|image)$/
|
10
10
|
field :description, String, 'Metadata Definition Description'
|
11
11
|
field :searchable, Symbol, 'Indexed and searchable', :true
|
12
12
|
field :editable, Symbol, 'Editable field', :true
|
13
13
|
field :required, Symbol, 'Required mandatory metadata item', :true
|
14
|
-
field :formType, String, 'Form control type'
|
14
|
+
field :formType, String, 'Form control type', 'textarea' , /^(select|textarea|text|checkbox|file)$/
|
15
15
|
field :maxLength, Fixnum, 'MaxLength', -1
|
16
16
|
field :validationHandler, String, 'Validation handler', ''
|
17
17
|
field :options, Array, 'Array of options', []
|
@@ -22,24 +22,17 @@ class Mio
|
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
md = metadata_definitions[r].find{|md| md['name'] == metadata_definition_name}
|
30
|
-
if md.nil?
|
31
|
-
raise Mio::Model::NoSuchResource, 'No such metadata definition[' + metadata_definition_name + ']'
|
25
|
+
def config_hash
|
26
|
+
metadata_definition = @search.find_metadataDefinitions_by_name(@args.metadataDefinition).first
|
27
|
+
if metadata_definition.nil?
|
28
|
+
raise Mio::Model::NoSuchResource, 'No such metadata definition [' + @args.metadataDefinition + ']'
|
32
29
|
end
|
33
30
|
|
34
|
-
md['id']
|
35
|
-
end
|
36
|
-
|
37
|
-
def config_hash
|
38
31
|
{"name": @args.name,
|
39
32
|
"asset-type": 'group-asset',
|
40
33
|
"creation-context": @args.creationContext,
|
41
34
|
"variant-and-metadata": {"variant-name": @args.variantName,
|
42
|
-
"metadata-details": {"metadata-definition": {"id":
|
35
|
+
"metadata-details": {"metadata-definition": {"id": metadata_definition['id']}}
|
43
36
|
}
|
44
37
|
}
|
45
38
|
end
|
data/lib/mio/model/variant.rb
CHANGED
@@ -9,17 +9,6 @@ class Mio
|
|
9
9
|
field :metadataDefinitions, Array, 'Array of metadata definition names'
|
10
10
|
field :defaultMetadataDefinition, String, 'Default metadata definition name'
|
11
11
|
|
12
|
-
def object_type_id object_type_name
|
13
|
-
r = 'objectTypes'
|
14
|
-
all_object_types = @client.find_all(r)
|
15
|
-
object_type = all_object_types[r].find{|object_type| object_type['name'] == object_type_name}
|
16
|
-
if object_type.nil?
|
17
|
-
raise Mio::Model::NoSuchResource, 'No such object type [' + object_type_name + ']'
|
18
|
-
end
|
19
|
-
|
20
|
-
object_type['id']
|
21
|
-
end
|
22
|
-
|
23
12
|
def metadata_definition_hash metadata_definitions
|
24
13
|
r = 'metadataDefinitions'
|
25
14
|
all_metadata_definitions = @client.find_all(r)
|
@@ -56,8 +45,13 @@ class Mio
|
|
56
45
|
def create_hash
|
57
46
|
metadata_definitions = metadata_definition_hash @args.metadataDefinitions
|
58
47
|
|
48
|
+
object_type = @search.find_objectTypes_by_name(@args.objectType).first
|
49
|
+
if object_type.nil?
|
50
|
+
raise Mio::Model::NoSuchResource, 'No such object type [' + @args.objectType + ']'
|
51
|
+
end
|
52
|
+
|
59
53
|
{name: @args.name,
|
60
|
-
objectTypeId:
|
54
|
+
objectTypeId: object_type['id'],
|
61
55
|
defaultVariant: @args.defaultVariant,
|
62
56
|
metadataDefinitionIds: metadata_definition_ids(metadata_definitions, @args.metadataDefinitions),
|
63
57
|
defaultMetadataDefinition: metadata_definition_id(metadata_definitions, @args.defaultMetadataDefinition)}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mio-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jspc
|
@@ -117,6 +117,9 @@ files:
|
|
117
117
|
- "./lib/mio/model/groovy_script_wait.rb"
|
118
118
|
- "./lib/mio/model/hotfolder.rb"
|
119
119
|
- "./lib/mio/model/import_action.rb"
|
120
|
+
- "./lib/mio/model/launch_workflow_action.rb"
|
121
|
+
- "./lib/mio/model/launchworkflow/launch_workflow.rb"
|
122
|
+
- "./lib/mio/model/launchworkflow/workflow_variable.rb"
|
120
123
|
- "./lib/mio/model/message_template.rb"
|
121
124
|
- "./lib/mio/model/metadata_definition.rb"
|
122
125
|
- "./lib/mio/model/metadatadefinition/definition.rb"
|