Red Hat NETWORK PROXY SERVER 3.7 - Informacje Techniczne Strona 52

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 63
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 51
import json
import requests
# Define Satellite location and login details
SAT_API = "https://localhost/api/v2/"
POST_HEADERS = {'content-type': 'application/json'}
USERNAME = "admin"
PASSWORD = "changeme"
SSL_VERIFY = False
def get_json(location):
"""
Performs a GET using the passed URL location
"""
r = requests.get(location, auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY)
return r.json()
def post_json(location, json_data):
"""
Performs a POST and passes the data to the URL location
"""
result = requests.post(
location,
data=json_data,
auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY,
headers=POST_HEADERS)
return result.json()
def delete_json(location):
"""
Performs a DELETE and passes the id to the URL location
"""
result = requests.delete(
location,
auth=(USERNAME, PASSWORD),
verify=SSL_VERIFY)
return result.json()
def main():
# List all users within the Satellite
users = get_json(SAT_API + "users/")
#print json.dumps(users, indent=4)
print "Users known are:"
for login in users['results']:
print login['login']
# Look for user example and if found, delete the user
for delete in users['results']:
if delete['login'] == 'example':
id = delete ['id']
Red Hat Sat ellit e 6 .0 T ransit ion G uid e
4 8
Przeglądanie stron 51
1 2 ... 47 48 49 50 51 52 53 54 55 56 57 ... 62 63

Komentarze do niniejszej Instrukcji

Brak uwag