File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ """
3+ Add hosts to an existing target
4+
5+ This action may only be performed by users with the required permissions,
6+ target API keys will no be able to create targets.
7+
8+ """
9+ import requests
10+ from urllib .parse import urljoin
11+
12+ token = input ("API Token: " )
13+ target_id = input ("Target ID: " )
14+
15+ headers = {
16+ 'Authorization' : "JWT {}" .format (token ),
17+ 'Content-Type' : "application/json" ,
18+ }
19+ api_base_url = "https://api.stg.probely.com"
20+ endpoint = urljoin (api_base_url , "targets/{target_id}/assets/" )
21+
22+ response = requests .post (
23+ endpoint .format (target_id = target_id ),
24+ headers = headers ,
25+ json = {'host' : 'example.com' })
26+
27+ print (response .request .headers )
28+
29+ if response .status_code == 200 :
30+ print ('\n SUCCESS' )
31+
32+ else :
33+ print ('\n [%s]\n %s' % (response .status_code , response .text ))
You can’t perform that action at this time.
0 commit comments