]> git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/remote.pm
8cedf083e3df2d29a163f86820a0ecf4476bfcbf
[pve-client.git] / PVE / APIClient / Commands / remote.pm
1 package PVE::APIClient::Commands::remote;
2
3 use strict;
4 use warnings;
5
6 use PVE::JSONSchema qw(register_standard_option get_standard_option);
7 use PVE::APIClient::Config;
8
9 use PVE::CLIHandler;
10
11 use base qw(PVE::CLIHandler);
12
13 my $complete_remote_name = sub {
14
15 my $config = PVE::APIClient::Config->new();
16 my $known_remotes = $config->remotes;
17
18 return [keys %{$known_remotes}];
19 };
20
21 register_standard_option('pveclient-remote-name', {
22 description => "The name of the remote.",
23 type => 'string',
24 pattern => qr([\w\d\.\-\_]+),
25 completion => $complete_remote_name,
26 });
27
28 __PACKAGE__->register_method ({
29 name => 'add',
30 path => 'add',
31 method => 'POST',
32 description => "Add a remote to your config file.",
33 parameters => {
34 additionalProperties => 0,
35 properties => {
36 name => get_standard_option('pveclient-remote-name', { completion => sub {} }),
37 host => {
38 description => "The host, either host, host:port or https://host:port",
39 type => 'string',
40 },
41 username => {
42 description => "The username.",
43 type => 'string',
44 optional => 1,
45 },
46 },
47 },
48 returns => { type => 'null'},
49 code => sub {
50 my ($param) = @_;
51
52 die "implement me";
53
54 }});
55
56 __PACKAGE__->register_method ({
57 name => 'remove',
58 path => 'remove',
59 method => 'DELETE',
60 description => "Removes a remote from your config file.",
61 parameters => {
62 additionalProperties => 0,
63 properties => {
64 name => get_standard_option('pveclient-remote-name'),
65 },
66 },
67 returns => { type => 'null'},
68 code => sub {
69 my ($param) = @_;
70
71 die "implement me";
72
73 }});
74
75 our $cmddef = {
76 add => [ __PACKAGE__, 'add', ['name', 'host']],
77 remove => [ __PACKAGE__, 'remove', ['name']],
78 };
79
80 1;