1 #!env perl
2
3 use strict;
4 use warnings;
5
6 use LWP;
7 use JSON qw( decode_json);
8
9 my $ua = LWP::UserAgent->new(ssl_opts => {SSL_verify_mode => 0,verify_hostname => 0,});
10 my @name = qw/aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss/;
11
12 #search first to get id
13 for (@name){
14 my $uri = 'http://10.117.4.218/api/search?q='.$_.'';
15 my $req = HTTP::Request->new('GET',$uri);
16 $req->authorization_basic('admin','Harbor12345');
17 my $res = $ua->request($req);
18 my $json = $res->content();
19 my $decoded = decode_json($json);
20 my $proj = $decoded->{project};
21 my @id = @{$proj};
22 for (@id){
23 print $_->{id};
24 my $uri = 'http://127.0.0.1/api/projects/'.$_->{id}.'';
25 my $req = HTTP::Request->new('DELETE',$uri);
26 $req->header('Content-Type' => 'application/json');
27 $req->authorization_basic('admin','Harbor12345');
28 my $res = $ua->request($req);
29 print $res->status_line()."\n";
30 }
31 }