Ubuntu Pastebin

Paste from vv at Fri, 23 Dec 2016 06:43:12 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  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 }
Download as text