xapixctl 1.1.2 → 1.2.4
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 +55 -37
- data/lib/xapixctl.rb +0 -3
- data/lib/xapixctl/base_cli.rb +47 -35
- data/lib/xapixctl/cli.rb +51 -66
- data/lib/xapixctl/connector_cli.rb +49 -0
- data/lib/xapixctl/phoenix_client.rb +37 -259
- 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: 0650e8d61c4e4d43e38d195c74ad139484db57c0bd761af93ff2ea2a7a083217
|
4
|
+
data.tar.gz: 4878b54c4c48002b4e8d5131c62178a26ea2e4c0c12cb4b4e697ef3c43c25565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 780557e28161b7a8c8fb1fe49f209ad86000d046cc244b654009c49f3c85628607d00a18a2d8879e60e9d0f883ac4333533dfc46b06f37e52d545fa6dd5c935b
|
7
|
+
data.tar.gz: 72c2a0ec1a8f4bd517d97a186b63de572b03063601d4d6290ef198724a2b254c2c35e1ec97fc56e7fd0c853500c5ac286b8289c25e47d8483415345854833946
|
@@ -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.4)
|
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
|
-
|
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)
|
19
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 (
|
72
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
73
|
+
rubocop-ast (1.4.1)
|
68
74
|
parser (>= 2.7.1.5)
|
69
|
-
|
70
|
-
|
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,65 +1,77 @@
|
|
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
|
25
|
+
def exit_with_api_error(err, result)
|
16
26
|
details = result['errors'].map { |k| k['detail'] }.unshift('').join("\n ") rescue err.to_s
|
17
|
-
warn "
|
27
|
+
warn "API error: #{details}"
|
18
28
|
exit 1
|
19
29
|
end
|
20
30
|
|
21
31
|
def show_deployment_status(result)
|
22
32
|
return unless result && result['project_publication']
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
say "deployment: #{result.dig('project_publication', 'deployment')}"
|
34
|
+
shell.indent do
|
35
|
+
say "data api: #{result.dig('project_publication', 'data_api')} (version: #{result.dig('project_publication', 'data_api_version').presence || 'n/a'})"
|
36
|
+
say "user management: #{result.dig('project_publication', 'user_management')}"
|
37
|
+
if result.dig('project_publication', 'deployment') == 'success'
|
38
|
+
say "base URL: #{result.dig('project_publication', 'base_url')}"
|
39
|
+
end
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
43
|
+
def connection
|
44
|
+
@connection ||= begin
|
45
|
+
url = options[:xapix_url] || ENV['XAPIX_URL'] || 'https://cloud.xapix.io/'
|
46
|
+
token = options[:xapix_token] || ENV['XAPIX_TOKEN']
|
47
|
+
raise Thor::RequiredArgumentMissingError, "No XAPIX_TOKEN given. Either use --xapix_token [TOKEN] or set environment variable XAPIX_TOKEN (recommended)" if !token
|
48
|
+
PhoenixClient.connection(
|
49
|
+
url, token,
|
50
|
+
default_error_handler: ->(err, result) { exit_with_api_error(err, result) },
|
51
|
+
logging: options[:debug] ? 'stdout' : nil
|
52
|
+
)
|
42
53
|
end
|
43
54
|
end
|
44
55
|
|
45
|
-
def
|
46
|
-
|
47
|
-
yield $stdin.read
|
48
|
-
else
|
49
|
-
pn = Pathname.new(filename)
|
50
|
-
if pn.directory?
|
51
|
-
pn.glob(["**/*.yaml", "**/*.yml"]).sort.each { |dpn| yield dpn.read }
|
52
|
-
else
|
53
|
-
yield pn.read
|
54
|
-
end
|
55
|
-
end
|
56
|
+
def org_or_prj_connection
|
57
|
+
options[:project] ? prj_connection : org_connection
|
56
58
|
end
|
57
59
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
def org_connection
|
61
|
+
org = options[:org] || ENV['XAPIX_ORG']
|
62
|
+
raise Thor::RequiredArgumentMissingError, "No organization given. Either use --org [ORG] or set environment variable XAPIX_ORG" if !org
|
63
|
+
@org_connection ||= connection.organization(org)
|
64
|
+
end
|
65
|
+
|
66
|
+
def prj_connection
|
67
|
+
project = options[:project] || ENV['XAPIX_PROJECT']
|
68
|
+
org = options[:org] || ENV['XAPIX_ORG']
|
69
|
+
raise Thor::RequiredArgumentMissingError, "No project given. Either use --project [ORG/PROJECT] or set environment variable XAPIX_PROJECT" if !project
|
70
|
+
if project.include?('/')
|
71
|
+
org, project = project.split('/', 2)
|
72
|
+
end
|
73
|
+
raise Thor::RequiredArgumentMissingError, "No organization given. Either use --org [ORG] or set environment variable XAPIX_ORG" if !org
|
74
|
+
@prj_connection ||= connection.project(org: org, project: project)
|
63
75
|
end
|
64
76
|
end
|
65
77
|
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,24 +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 { |resource_ids| resource_ids.each { |res_id| get(resource_type, res_id) } }
|
41
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
42
|
-
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
|
+
say conn.resource(resource_type, res_id, format: options[:format].to_sym)
|
43
48
|
end
|
44
49
|
end
|
45
50
|
|
46
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
47
|
-
option :project, aliases: "-p", desc: "Project", required: true
|
48
51
|
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
49
52
|
desc "export", "retrieves all resources within a project"
|
50
53
|
long_desc <<-LONGDESC
|
@@ -54,19 +57,15 @@ module Xapixctl
|
|
54
57
|
|
55
58
|
Examples:
|
56
59
|
\x5> $ xapixctl export -o xapix -p some-project
|
57
|
-
\x5> $ xapixctl export -
|
60
|
+
\x5> $ xapixctl export -p xapix/some-project
|
61
|
+
\x5> $ xapixctl export -p xapix/some-project -f yaml > some_project.yaml
|
58
62
|
LONGDESC
|
59
63
|
def export
|
60
|
-
|
61
|
-
|
62
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
63
|
-
end
|
64
|
-
(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) }
|
65
66
|
end
|
66
67
|
|
67
|
-
option :
|
68
|
-
option :project, aliases: "-p", desc: "Project"
|
69
|
-
option :file, aliases: "-f", required: true
|
68
|
+
option :file, aliases: "-f", required: true, desc: 'file or directory from which to load resource descriptions'
|
70
69
|
desc "apply", "Create or update a resource from a file"
|
71
70
|
long_desc <<-LONGDESC
|
72
71
|
`xapixctl apply -f FILE` will apply the given resource description.
|
@@ -82,24 +81,20 @@ module Xapixctl
|
|
82
81
|
Examples:
|
83
82
|
\x5> $ xapixctl apply -o xapix -f get_a_list.yaml
|
84
83
|
\x5> $ xapixctl apply -o xapix -p some-project -f get_a_list.yaml
|
85
|
-
\x5> $ xapixctl apply -
|
84
|
+
\x5> $ xapixctl apply -p xapix/some-project -f get_a_list.yaml
|
85
|
+
\x5> $ xapixctl apply -p xapix/some-project -f ./
|
86
86
|
|
87
87
|
To copy over all data sources from one project to another:
|
88
88
|
\x5> $ xapixctl get -o xapix-old -p some-project DataSource -f yaml | xapixctl apply -o xapix-new -f -
|
89
89
|
LONGDESC
|
90
90
|
def apply
|
91
|
-
resources_from_file(options[:file]) do |desc|
|
92
|
-
|
93
|
-
|
94
|
-
res.on_success { puts 'OK' }
|
95
|
-
res.on_error { |err, result| warn_api_error("could not apply changes", err, result); break }
|
96
|
-
end
|
91
|
+
Util.resources_from_file(options[:file]) do |desc|
|
92
|
+
say "applying #{desc['kind']} #{desc.dig('metadata', 'id')}"
|
93
|
+
org_or_prj_connection.apply(desc)
|
97
94
|
end
|
98
95
|
end
|
99
96
|
|
100
|
-
option :
|
101
|
-
option :project, aliases: "-p", desc: "Project"
|
102
|
-
option :file, aliases: "-f"
|
97
|
+
option :file, aliases: "-f", desc: 'file or directory from which to load resource descriptions'
|
103
98
|
desc "delete [TYPE ID] [-f FILE]", "delete the resources in the file"
|
104
99
|
long_desc <<-LONGDESC
|
105
100
|
`xapixctl delete -f FILE` will delete all the resources listed in the file.
|
@@ -110,22 +105,20 @@ module Xapixctl
|
|
110
105
|
You can also read from stdin by using '-'.
|
111
106
|
|
112
107
|
Examples:
|
113
|
-
\x5> $ xapixctl delete -o xapix -p some-project -f get_a_list.yaml
|
114
|
-
\x5> $ xapixctl delete -o xapix -p some-project -f ./
|
115
|
-
\x5> $ xapixctl delete -o xapix -p some-project DataSource get-a-list
|
116
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 ./
|
117
113
|
LONGDESC
|
118
114
|
def delete(resource_type = nil, resource_id = nil)
|
119
115
|
if resource_type && resource_id
|
120
|
-
|
121
|
-
|
122
|
-
res.on_error { |err, result| warn_api_error("could not delete", err, result) }
|
123
|
-
end
|
116
|
+
org_or_prj_connection.delete(resource_type, resource_id)
|
117
|
+
say "DELETED #{resource_type} #{resource_id}"
|
124
118
|
elsif options[:file]
|
125
|
-
resources_from_file(options[:file]) do |desc|
|
119
|
+
Util.resources_from_file(options[:file]) do |desc|
|
126
120
|
res_type = desc['kind']
|
127
121
|
res_id = desc.dig('metadata', 'id')
|
128
|
-
puts "deleting #{res_type} #{res_id}"
|
129
122
|
delete(res_type, res_id)
|
130
123
|
end
|
131
124
|
else
|
@@ -133,24 +126,21 @@ module Xapixctl
|
|
133
126
|
end
|
134
127
|
end
|
135
128
|
|
136
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
137
|
-
option :project, aliases: "-p", desc: "Project", required: true
|
138
129
|
desc "publish", "Publishes the current version of the given project"
|
139
130
|
long_desc <<-LONGDESC
|
140
131
|
`xapixctl publish` will publish the given project.
|
141
132
|
|
142
133
|
Examples:
|
143
134
|
\x5> $ xapixctl publish -o xapix -p some-project
|
135
|
+
\x5> $ xapixctl publish -p xapix/some-project
|
144
136
|
LONGDESC
|
145
137
|
def publish
|
146
|
-
|
138
|
+
prj_connection.publish do |res|
|
147
139
|
res.on_success { |result| show_deployment_status(result) }
|
148
|
-
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) }
|
149
141
|
end
|
150
142
|
end
|
151
143
|
|
152
|
-
option :org, aliases: "-o", desc: "Organization", required: true
|
153
|
-
option :project, aliases: "-p", desc: "Project", required: true
|
154
144
|
desc "logs CORRELATION_ID", "Retrieves the execution logs for the given correlation ID"
|
155
145
|
long_desc <<-LONGDESC
|
156
146
|
`xapixctl logs CORRELATION_ID` will retrieve execution logs for the given correlation ID.
|
@@ -159,28 +149,23 @@ module Xapixctl
|
|
159
149
|
|
160
150
|
Examples:
|
161
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
|
162
153
|
LONGDESC
|
163
154
|
def logs(correlation_id)
|
164
|
-
|
165
|
-
|
166
|
-
res.on_error { |err, result| warn_api_error('could not get logs', err, result) }
|
167
|
-
end
|
155
|
+
result = prj_connection.logs(correlation_id)
|
156
|
+
say result['logs'].to_yaml
|
168
157
|
end
|
169
158
|
|
170
159
|
SUPPORTED_CONTEXTS = ['Project', 'Organization'].freeze
|
160
|
+
|
171
161
|
desc "api-resources", "retrieves a list of all available resource types"
|
172
162
|
def api_resources
|
173
|
-
connection.available_resource_types
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
available_types.sort_by { |desc| desc['type'] }.each do |desc|
|
178
|
-
next unless SUPPORTED_CONTEXTS.include?(desc['context'])
|
179
|
-
puts format_str % [desc['type'], desc['context']]
|
180
|
-
end
|
181
|
-
end
|
182
|
-
res.on_error { |err, result| warn_api_error("could not get", err, result) }
|
163
|
+
available_types = connection.available_resource_types.sort_by { |desc| desc['type'] }.filter { |desc| SUPPORTED_CONTEXTS.include?(desc['context']) }
|
164
|
+
table = [['Type', 'Required Context', '']]
|
165
|
+
table += available_types.map do |desc|
|
166
|
+
[desc['type'], desc['context'], PhoenixClient.supported_type?(desc['type']) ? '' : '(unsupported, update CLI)']
|
183
167
|
end
|
168
|
+
print_table table, indent: 1
|
184
169
|
end
|
185
170
|
end
|
186
171
|
end
|