Red Hat NETWORK PROXY SERVER 3.7 - Informacje Techniczne Strona 53

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 63
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 52
id = str(id)
delete = delete_json(SAT_API + "/users/" + id)
#print json.dumps(delete, indent=4)
print "User example deleted"
# Create a user called example as admin role
createuser = post_json(SAT_API + "/users/", json.dumps({ "mail":
"root@ localhost", "firstname": "Example", "lastname": "User", "login":
"example", "password": "redhat", "admin": 'true', "auth_source_id": 1 }))
#print json.dumps(createuser, indent=4)
print "Admin user example created"
if __name__ == "__main__":
main()
Usin g Rub y t o Man age Users on Satellite 6
This example uses Ruby to perform the same task as the previous examples.
#!/usr/bin/ruby193-ruby
require 'json'
require 'rest-client'
url = 'https://localhost/api/v2/'
$username = 'admin'
$password = 'changeme'
def get_json(location)
response = RestClient::Request.new(
:method => :get,
:url => location,
:user => $username,
:password => $password,
:headers => { :accept => :json,
:content_type => :json }
).execute
results = JSON.parse(response.to_str)
end
def post_json(location, json_data)
response = RestClient::Request.new(
:method => :post,
:url => location,
:user => $username,
:password => $password,
:headers => { :accept => :json,
:content_type => :json},
:payload => json_data
).execute
results = JSON.parse(response.to_str)
end
def delete_json(location)
response = RestClient::Request.new(
Chapt er 4 . Advanced T ransit ioning
4 9
Przeglądanie stron 52
1 2 ... 48 49 50 51 52 53 54 55 56 57 58 ... 62 63

Komentarze do niniejszej Instrukcji

Brak uwag