xapixctl 1.1.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/cd.yaml +17 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +57 -39
- data/lib/xapixctl.rb +0 -3
- data/lib/xapixctl/base_cli.rb +43 -19
- data/lib/xapixctl/cli.rb +56 -76
- data/lib/xapixctl/connector_cli.rb +49 -0
- data/lib/xapixctl/phoenix_client.rb +36 -258
- data/lib/xapixctl/phoenix_client/connection.rb +50 -0
- data/lib/xapixctl/phoenix_client/organization_connection.rb +61 -0
- data/lib/xapixctl/phoenix_client/project_connection.rb +184 -0
- data/lib/xapixctl/phoenix_client/result_handler.rb +35 -0
- data/lib/xapixctl/preview_cli.rb +7 -19
- data/lib/xapixctl/sync_cli.rb +241 -0
- data/lib/xapixctl/titan_cli.rb +286 -0
- data/lib/xapixctl/util.rb +42 -0
- data/lib/xapixctl/version.rb +1 -1
- data/xapixctl.gemspec +12 -4
- metadata +83 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb1bf2d6f83193e0b5d1341fbfc1177c7c76802a2aa0cdef748f3d9eb0e7d11
|
4
|
+
data.tar.gz: 742c9ce8f28477d6bf922196c1d0d192ec1648db7fbe1cc73a1aba673c307f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ecb583e67e5210f5cc9c2333d519e6bc160b7e0d8eb5236c407825acca54fc0dd1bfac178d2f0abef4becd29e5cc4b46bdc1d6e0c4ffcda79ab969a2d5846f
|
7
|
+
data.tar.gz: 5ee3f1ef369eb548117d7e277884348ea9cc4885f650bae9c3bb4191a72e7f4d3261ceb05b97f53ca2ee04c2a917fbd2937e96d024b4e4a690d3a0fe37926d80
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: CD
|
2
|
+
on: push
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
strategy:
|
7
|
+
matrix:
|
8
|
+
ruby-version: [2.7, 2.6]
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
12
|
+
uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: ${{ matrix.ruby-version }}
|
15
|
+
bundler-cache: true
|
16
|
+
- name: Run tests
|
17
|
+
run: bundle exec rspec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.3
|
data/Gemfile.lock
CHANGED
@@ -1,40 +1,46 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
xapixctl (1.
|
4
|
+
xapixctl (1.2.3)
|
5
5
|
activesupport (>= 5.2.3, < 6.0.0)
|
6
|
+
hashdiff (>= 1.0.1, < 1.2.0)
|
6
7
|
rest-client (>= 2.1.0, < 3.0.0)
|
7
|
-
thor (>= 1.0.0, < 1.
|
8
|
+
thor (>= 1.0.0, < 1.2.0)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
activesupport (5.2.4.
|
13
|
+
activesupport (5.2.4.5)
|
13
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
15
|
i18n (>= 0.7, < 2)
|
15
16
|
minitest (~> 5.1)
|
16
17
|
tzinfo (~> 1.1)
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
addressable (2.7.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
ast (2.4.2)
|
21
|
+
concurrent-ruby (1.1.8)
|
22
|
+
crack (0.4.4)
|
23
|
+
diff-lcs (1.4.4)
|
20
24
|
domain_name (0.5.20190701)
|
21
25
|
unf (>= 0.0.5, < 1.0.0)
|
26
|
+
hashdiff (1.0.1)
|
22
27
|
http-accept (1.7.0)
|
23
28
|
http-cookie (1.0.3)
|
24
29
|
domain_name (~> 0.5)
|
25
|
-
i18n (1.8.
|
30
|
+
i18n (1.8.9)
|
26
31
|
concurrent-ruby (~> 1.0)
|
27
32
|
mime-types (3.3.1)
|
28
33
|
mime-types-data (~> 3.2015)
|
29
|
-
mime-types-data (3.
|
30
|
-
minitest (5.14.
|
34
|
+
mime-types-data (3.2021.0225)
|
35
|
+
minitest (5.14.4)
|
31
36
|
netrc (0.11.0)
|
32
|
-
parallel (1.
|
33
|
-
parser (
|
37
|
+
parallel (1.20.1)
|
38
|
+
parser (3.0.0.0)
|
34
39
|
ast (~> 2.4.1)
|
40
|
+
public_suffix (4.0.6)
|
35
41
|
rainbow (3.0.0)
|
36
|
-
rake (13.0.
|
37
|
-
regexp_parser (1.
|
42
|
+
rake (13.0.3)
|
43
|
+
regexp_parser (2.1.1)
|
38
44
|
relaxed-rubocop (2.5)
|
39
45
|
rest-client (2.1.0)
|
40
46
|
http-accept (>= 1.7.0, < 2.0)
|
@@ -42,50 +48,62 @@ GEM
|
|
42
48
|
mime-types (>= 1.16, < 4.0)
|
43
49
|
netrc (~> 0.8)
|
44
50
|
rexml (3.2.4)
|
45
|
-
rspec (3.
|
46
|
-
rspec-core (~> 3.
|
47
|
-
rspec-expectations (~> 3.
|
48
|
-
rspec-mocks (~> 3.
|
49
|
-
rspec-core (3.
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-expectations (3.
|
51
|
+
rspec (3.10.0)
|
52
|
+
rspec-core (~> 3.10.0)
|
53
|
+
rspec-expectations (~> 3.10.0)
|
54
|
+
rspec-mocks (~> 3.10.0)
|
55
|
+
rspec-core (3.10.1)
|
56
|
+
rspec-support (~> 3.10.0)
|
57
|
+
rspec-expectations (3.10.1)
|
52
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
-
rspec-support (~> 3.
|
54
|
-
rspec-mocks (3.
|
59
|
+
rspec-support (~> 3.10.0)
|
60
|
+
rspec-mocks (3.10.2)
|
55
61
|
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
-
rspec-support (~> 3.
|
57
|
-
rspec-support (3.
|
58
|
-
rubocop (
|
62
|
+
rspec-support (~> 3.10.0)
|
63
|
+
rspec-support (3.10.2)
|
64
|
+
rubocop (1.11.0)
|
59
65
|
parallel (~> 1.10)
|
60
|
-
parser (>=
|
66
|
+
parser (>= 3.0.0.0)
|
61
67
|
rainbow (>= 2.2.2, < 4.0)
|
62
|
-
regexp_parser (>= 1.
|
68
|
+
regexp_parser (>= 1.8, < 3.0)
|
63
69
|
rexml
|
64
|
-
rubocop-ast (>=
|
70
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
65
71
|
ruby-progressbar (~> 1.7)
|
66
|
-
unicode-display_width (>= 1.4.0, <
|
67
|
-
rubocop-ast (
|
68
|
-
parser (>= 2.7.1.
|
69
|
-
|
70
|
-
|
72
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
73
|
+
rubocop-ast (1.4.1)
|
74
|
+
parser (>= 2.7.1.5)
|
75
|
+
rubocop-rake (0.5.1)
|
76
|
+
rubocop
|
77
|
+
rubocop-rspec (2.2.0)
|
78
|
+
rubocop (~> 1.0)
|
79
|
+
rubocop-ast (>= 1.1.0)
|
80
|
+
ruby-progressbar (1.11.0)
|
81
|
+
thor (1.1.0)
|
71
82
|
thread_safe (0.3.6)
|
72
|
-
tzinfo (1.2.
|
83
|
+
tzinfo (1.2.9)
|
73
84
|
thread_safe (~> 0.1)
|
74
85
|
unf (0.1.4)
|
75
86
|
unf_ext
|
76
87
|
unf_ext (0.0.7.7)
|
77
|
-
unicode-display_width (
|
88
|
+
unicode-display_width (2.0.0)
|
89
|
+
webmock (3.11.0)
|
90
|
+
addressable (>= 2.3.6)
|
91
|
+
crack (>= 0.3.2)
|
92
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
78
93
|
|
79
94
|
PLATFORMS
|
80
95
|
ruby
|
81
96
|
|
82
97
|
DEPENDENCIES
|
83
|
-
bundler (~> 1.
|
98
|
+
bundler (~> 2.1.4)
|
84
99
|
rake (~> 13.0)
|
85
100
|
relaxed-rubocop (~> 2.5)
|
86
|
-
rspec (~> 3.0)
|
87
|
-
rubocop (~> 0
|
101
|
+
rspec (~> 3.10.0)
|
102
|
+
rubocop (~> 1.11.0)
|
103
|
+
rubocop-rake (~> 0.5.1)
|
104
|
+
rubocop-rspec (~> 2.2.0)
|
105
|
+
webmock (~> 3.11.0)
|
88
106
|
xapixctl!
|
89
107
|
|
90
108
|
BUNDLED WITH
|
91
|
-
1.
|
109
|
+
2.1.4
|
data/lib/xapixctl.rb
CHANGED
@@ -4,9 +4,6 @@ require 'active_support'
|
|
4
4
|
require 'active_support/core_ext/hash/keys'
|
5
5
|
require 'active_support/core_ext/object/blank'
|
6
6
|
require 'active_support/core_ext/string/inflections'
|
7
|
-
require 'rest_client'
|
8
|
-
require 'json'
|
9
|
-
require 'psych'
|
10
7
|
require 'xapixctl/version'
|
11
8
|
require 'xapixctl/phoenix_client'
|
12
9
|
|
data/lib/xapixctl/base_cli.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'thor'
|
4
|
+
require 'xapixctl/util'
|
4
5
|
|
5
6
|
module Xapixctl
|
6
7
|
class BaseCli < Thor
|
7
8
|
def self.exit_on_failure?; true; end
|
8
9
|
|
9
|
-
|
10
|
+
def self.start(given_args = ARGV, config = {})
|
11
|
+
super
|
12
|
+
rescue StandardError => err
|
13
|
+
config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise err) : config[:shell].error(err.message)
|
14
|
+
exit(false) if exit_on_failure?
|
15
|
+
end
|
16
|
+
|
17
|
+
class_option :org, aliases: "-o", desc: "Organization; Fallback: environment variable XAPIX_ORG"
|
18
|
+
class_option :project, aliases: "-p", desc: "Project, can be ORG/PROJECT; Fallback: environment variable XAPIX_PROJECT"
|
19
|
+
class_option :debug, type: :boolean, desc: "Print details for debugging"
|
10
20
|
class_option :xapix_url, desc: "Fallback: environment variable XAPIX_URL. URL to Xapix. Default: https://cloud.xapix.io/"
|
11
21
|
class_option :xapix_token, desc: "Fallback: environment variable XAPIX_TOKEN. Your access token."
|
12
22
|
|
13
23
|
private
|
14
24
|
|
15
|
-
def
|
16
|
-
details =
|
17
|
-
warn "
|
25
|
+
def exit_with_api_error(err, result)
|
26
|
+
details = result['errors'].map { |k| k['detail'] }.unshift('').join("\n ") rescue err.to_s
|
27
|
+
warn "API error: #{details}"
|
18
28
|
exit 1
|
19
29
|
end
|
20
30
|
|
@@ -28,24 +38,38 @@ module Xapixctl
|
|
28
38
|
end
|
29
39
|
end
|
30
40
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
def connection
|
42
|
+
@connection ||= begin
|
43
|
+
url = options[:xapix_url] || ENV['XAPIX_URL'] || 'https://cloud.xapix.io/'
|
44
|
+
token = options[:xapix_token] || ENV['XAPIX_TOKEN']
|
45
|
+
raise Thor::RequiredArgumentMissingError, "No XAPIX_TOKEN given. Either use --xapix_token [TOKEN] or set environment variable XAPIX_TOKEN (recommended)" if !token
|
46
|
+
PhoenixClient.connection(
|
47
|
+
url, token,
|
48
|
+
default_error_handler: ->(err, result) { exit_with_api_error(err, result) },
|
49
|
+
logging: options[:debug] ? 'stdout' : nil
|
50
|
+
)
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
def org_or_prj_connection
|
55
|
+
options[:project] ? prj_connection : org_connection
|
56
|
+
end
|
57
|
+
|
58
|
+
def org_connection
|
59
|
+
org = options[:org] || ENV['XAPIX_ORG']
|
60
|
+
raise Thor::RequiredArgumentMissingError, "No organization given. Either use --org [ORG] or set environment variable XAPIX_ORG" if !org
|
61
|
+
@org_connection ||= connection.organization(org)
|
62
|
+
end
|
63
|
+
|
64
|
+
def prj_connection
|
65
|
+
project = options[:project] || ENV['XAPIX_PROJECT']
|
66
|
+
org = options[:org] || ENV['XAPIX_ORG']
|
67
|
+
raise Thor::RequiredArgumentMissingError, "No project given. Either use --project [ORG/PROJECT] or set environment variable XAPIX_PROJECT" if !project
|
68
|
+
if project.include?('/')
|
69
|
+
org, project = project.split('/', 2)
|
70
|
+
end
|
71
|
+
raise Thor::RequiredArgumentMissingError, "No organization given. Either use --org [ORG] or set environment variable XAPIX_ORG" if !org
|
72
|
+
@prj_connection ||= connection.project(org: org, project: project)
|
49
73
|
end
|
50
74
|
end
|
51
75
|
end
|
data/lib/xapixctl/cli.rb
CHANGED
@@ -1,25 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'xapixctl/base_cli'
|
4
|
+
require 'xapixctl/connector_cli'
|
4
5
|
require 'xapixctl/preview_cli'
|
6
|
+
require 'xapixctl/sync_cli'
|
7
|
+
require 'xapixctl/titan_cli'
|
5
8
|
|
6
9
|
module Xapixctl
|
7
10
|
class Cli < BaseCli
|
11
|
+
desc "connectors SUBCOMMAND ...ARGS", "Commands for Connector resources"
|
12
|
+
subcommand "connectors", ConnectorCli
|
13
|
+
|
8
14
|
desc "preview SUBCOMMAND ...ARGS", "Request preview for resources"
|
9
|
-
subcommand "preview",
|
15
|
+
subcommand "preview", PreviewCli
|
16
|
+
|
17
|
+
desc "sync SUBCOMMAND ...ARGS", "Sync resources"
|
18
|
+
subcommand "sync", SyncCli
|
19
|
+
|
20
|
+
desc "titan SUBCOMMAND ...ARGS", "Tools for ML model deployments and service generation", hide: true
|
21
|
+
subcommand "titan", TitanCli
|
10
22
|
|
11
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
12
|
-
option :project, aliases: "-p", desc: "Project"
|
13
23
|
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
14
24
|
desc "get TYPE [ID]", "retrieve either all resources of given TYPE or just the resource of given TYPE and ID"
|
15
25
|
long_desc <<-LONGDESC
|
16
26
|
`xapixctl get TYPE` will retrieve the list of all resources of given type.
|
17
27
|
|
18
28
|
If requested on an organization (i.e. no project given), the following types are available:
|
19
|
-
\
|
29
|
+
\x5Project
|
20
30
|
|
21
31
|
If requested on an a project (i.e. organization and project are given), the following types are available:
|
22
|
-
\x5
|
32
|
+
\x5#{PhoenixClient::SUPPORTED_RESOURCE_TYPES.sort.join(', ')}
|
23
33
|
|
24
34
|
Use the format to switch between the different output formats.
|
25
35
|
|
@@ -27,31 +37,17 @@ module Xapixctl
|
|
27
37
|
\x5> $ xapixctl get -o xapix Project
|
28
38
|
\x5> $ xapixctl get -o xapix Project some-project
|
29
39
|
\x5> $ xapixctl get -o xapix -p some-project DataSource
|
30
|
-
\x5> $ xapixctl get -
|
40
|
+
\x5> $ xapixctl get -p xapix/some-project DataSource
|
41
|
+
\x5> $ xapixctl get -p xapix/some-project DataSource get-a-list
|
31
42
|
LONGDESC
|
32
43
|
def get(resource_type, resource_id = nil)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
else
|
39
|
-
connection.resource_ids(resource_type, org: options[:org], project: options[:project]) do |res|
|
40
|
-
res.on_success do |resource_ids|
|
41
|
-
resource_ids.each do |resource_id|
|
42
|
-
connection.resource(resource_type, resource_id, org: options[:org], project: options[:project], format: options[:format].to_sym) do |res|
|
43
|
-
res.on_success { |resource| puts resource }
|
44
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
49
|
-
end
|
44
|
+
conn = org_or_prj_connection
|
45
|
+
resource_ids = resource_id ? [resource_id] : conn.resource_ids(resource_type)
|
46
|
+
resource_ids.each do |res_id|
|
47
|
+
puts conn.resource(resource_type, res_id, format: options[:format].to_sym)
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
54
|
-
option :project, aliases: "-p", desc: "Project", required: true
|
55
51
|
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
56
52
|
desc "export", "retrieves all resources within a project"
|
57
53
|
long_desc <<-LONGDESC
|
@@ -61,19 +57,15 @@ module Xapixctl
|
|
61
57
|
|
62
58
|
Examples:
|
63
59
|
\x5> $ xapixctl export -o xapix -p some-project
|
64
|
-
\x5> $ xapixctl export -
|
60
|
+
\x5> $ xapixctl export -p xapix/some-project
|
61
|
+
\x5> $ xapixctl export -p xapix/some-project -f yaml > some_project.yaml
|
65
62
|
LONGDESC
|
66
63
|
def export
|
67
|
-
|
68
|
-
|
69
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
70
|
-
end
|
71
|
-
(connection.resource_types_for_export - ['Project']).each { |type| get(type) }
|
64
|
+
get('Project', prj_connection.project)
|
65
|
+
prj_connection.resource_types_for_export.each { |type| get(type) }
|
72
66
|
end
|
73
67
|
|
74
|
-
option :
|
75
|
-
option :project, aliases: "-p", desc: "Project"
|
76
|
-
option :file, aliases: "-f", required: true
|
68
|
+
option :file, aliases: "-f", required: true, desc: 'file or directory from which to load resource descriptions'
|
77
69
|
desc "apply", "Create or update a resource from a file"
|
78
70
|
long_desc <<-LONGDESC
|
79
71
|
`xapixctl apply -f FILE` will apply the given resource description.
|
@@ -83,80 +75,72 @@ module Xapixctl
|
|
83
75
|
If applied on a project (i.e. organization and project are given), the given project is used.
|
84
76
|
|
85
77
|
The given file should be in YAML format and can contain multiple resource definitions, each as it's own YAML document.
|
78
|
+
You can also provide a directory, in which case all files with yml/yaml extension will get loaded.
|
86
79
|
You can also read from stdin by using '-'.
|
87
80
|
|
88
81
|
Examples:
|
89
82
|
\x5> $ xapixctl apply -o xapix -f get_a_list.yaml
|
90
83
|
\x5> $ xapixctl apply -o xapix -p some-project -f get_a_list.yaml
|
84
|
+
\x5> $ xapixctl apply -p xapix/some-project -f get_a_list.yaml
|
85
|
+
\x5> $ xapixctl apply -p xapix/some-project -f ./
|
91
86
|
|
92
87
|
To copy over all data sources from one project to another:
|
93
88
|
\x5> $ xapixctl get -o xapix-old -p some-project DataSource -f yaml | xapixctl apply -o xapix-new -f -
|
94
89
|
LONGDESC
|
95
90
|
def apply
|
96
|
-
resources_from_file(options[:file]) do |desc|
|
91
|
+
Util.resources_from_file(options[:file]) do |desc|
|
97
92
|
puts "applying #{desc['kind']} #{desc.dig('metadata', 'id')}"
|
98
|
-
|
99
|
-
res.on_success { puts 'OK' }
|
100
|
-
res.on_error { |err, result| warn_api_error("could not apply changes", err, result); break }
|
101
|
-
end
|
93
|
+
org_or_prj_connection.apply(desc)
|
102
94
|
end
|
103
95
|
end
|
104
96
|
|
105
|
-
option :
|
106
|
-
option :project, aliases: "-p", desc: "Project"
|
107
|
-
option :file, aliases: "-f"
|
97
|
+
option :file, aliases: "-f", desc: 'file or directory from which to load resource descriptions'
|
108
98
|
desc "delete [TYPE ID] [-f FILE]", "delete the resources in the file"
|
109
99
|
long_desc <<-LONGDESC
|
110
100
|
`xapixctl delete -f FILE` will delete all the resources listed in the file.
|
111
101
|
\x5`xapixctl delete TYPE ID` will delete the resource by given TYPE and ID.
|
112
102
|
|
113
103
|
The given file should be in YAML format and can contain multiple resource definitions, each as it's own YAML document.
|
104
|
+
You can also provide a directory, in which case all files with yml/yaml extension will get loaded.
|
114
105
|
You can also read from stdin by using '-'.
|
115
106
|
|
116
107
|
Examples:
|
117
|
-
\x5> $ xapixctl delete -o xapix -p some-project -f get_a_list.yaml
|
118
|
-
\x5> $ xapixctl delete -o xapix -p some-project DataSource get-a-list
|
119
108
|
\x5> $ xapixctl delete -o xapix Project some-project
|
109
|
+
\x5> $ xapixctl delete -p xapix -p some-project DataSource get-a-list
|
110
|
+
\x5> $ xapixctl delete -p xapix/some-project DataSource get-a-list
|
111
|
+
\x5> $ xapixctl delete -p xapix/some-project -f get_a_list.yaml
|
112
|
+
\x5> $ xapixctl delete -p xapix/some-project -f ./
|
120
113
|
LONGDESC
|
121
114
|
def delete(resource_type = nil, resource_id = nil)
|
122
115
|
if resource_type && resource_id
|
123
|
-
|
124
|
-
|
125
|
-
res.on_error { |err, result| warn_api_error("could not delete", err, result) }
|
126
|
-
end
|
116
|
+
org_or_prj_connection.delete(resource_type, resource_id)
|
117
|
+
puts "DELETED #{resource_type} #{resource_id}"
|
127
118
|
elsif options[:file]
|
128
|
-
resources_from_file(options[:file]) do |desc|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
connection.delete(type, id, org: options[:org], project: options[:project]) do |res|
|
133
|
-
res.on_success { puts "DELETED #{type} #{id}" }
|
134
|
-
res.on_error { |err, result| warn_api_error("could not delete", err, result); break }
|
135
|
-
end
|
119
|
+
Util.resources_from_file(options[:file]) do |desc|
|
120
|
+
res_type = desc['kind']
|
121
|
+
res_id = desc.dig('metadata', 'id')
|
122
|
+
delete(res_type, res_id)
|
136
123
|
end
|
137
124
|
else
|
138
125
|
warn "need TYPE and ID or --file option"
|
139
126
|
end
|
140
127
|
end
|
141
128
|
|
142
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
143
|
-
option :project, aliases: "-p", desc: "Project", required: true
|
144
129
|
desc "publish", "Publishes the current version of the given project"
|
145
130
|
long_desc <<-LONGDESC
|
146
131
|
`xapixctl publish` will publish the given project.
|
147
132
|
|
148
133
|
Examples:
|
149
134
|
\x5> $ xapixctl publish -o xapix -p some-project
|
135
|
+
\x5> $ xapixctl publish -p xapix/some-project
|
150
136
|
LONGDESC
|
151
137
|
def publish
|
152
|
-
|
138
|
+
prj_connection.publish do |res|
|
153
139
|
res.on_success { |result| show_deployment_status(result) }
|
154
|
-
res.on_error { |err, result| show_deployment_status(result);
|
140
|
+
res.on_error { |err, result| show_deployment_status(result); exit_with_api_error(err, result) }
|
155
141
|
end
|
156
142
|
end
|
157
143
|
|
158
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
159
|
-
option :project, aliases: "-p", desc: "Project", required: true
|
160
144
|
desc "logs CORRELATION_ID", "Retrieves the execution logs for the given correlation ID"
|
161
145
|
long_desc <<-LONGDESC
|
162
146
|
`xapixctl logs CORRELATION_ID` will retrieve execution logs for the given correlation ID.
|
@@ -165,27 +149,23 @@ module Xapixctl
|
|
165
149
|
|
166
150
|
Examples:
|
167
151
|
\x5> $ xapixctl logs be9c8608-e291-460d-bc20-5a394c4079d4 -o xapix -p some-project
|
152
|
+
\x5> $ xapixctl logs be9c8608-e291-460d-bc20-5a394c4079d4 -p xapix/some-project
|
168
153
|
LONGDESC
|
169
154
|
def logs(correlation_id)
|
170
|
-
|
171
|
-
|
172
|
-
res.on_error { |err, result| warn_api_error('could not get logs', err, result) }
|
173
|
-
end
|
155
|
+
result = prj_connection.logs(correlation_id)
|
156
|
+
puts result['logs'].to_yaml
|
174
157
|
end
|
175
158
|
|
176
159
|
SUPPORTED_CONTEXTS = ['Project', 'Organization'].freeze
|
160
|
+
|
177
161
|
desc "api-resources", "retrieves a list of all available resource types"
|
178
162
|
def api_resources
|
179
|
-
connection.available_resource_types
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
puts format_str % [desc['type'], desc['context']]
|
186
|
-
end
|
187
|
-
end
|
188
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
163
|
+
available_types = connection.available_resource_types
|
164
|
+
format_str = "%20.20s %20.20s %26.26s"
|
165
|
+
puts format_str % ['Type', 'Required Context', '']
|
166
|
+
available_types.sort_by { |desc| desc['type'] }.each do |desc|
|
167
|
+
next unless SUPPORTED_CONTEXTS.include?(desc['context'])
|
168
|
+
puts format_str % [desc['type'], desc['context'], PhoenixClient.supported_type?(desc['type']) ? '' : '(unsupported, update CLI)']
|
189
169
|
end
|
190
170
|
end
|
191
171
|
end
|