-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
83 lines (61 loc) · 2.28 KB
/
example_usage.py
File metadata and controls
83 lines (61 loc) · 2.28 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
"""
Example usage of the AAP Organization Inspector as a module
"""
from aap_org_inspector import AAPClient, OrganizationInspector
def example_programmatic_usage():
"""Example of using the inspector programmatically"""
# Configuration
AAP_URL = "https://aap.example.com"
USERNAME = "admin"
PASSWORD = "your_password"
ORG_NAME = "My Organization"
# Create client
client = AAPClient(
base_url=AAP_URL,
username=USERNAME,
password=PASSWORD,
verify_ssl=True # Set to False for self-signed certificates
)
# Create inspector
inspector = OrganizationInspector(client)
# Inspect organization
result = inspector.inspect_organization(ORG_NAME)
# Access the data
org = result['organization']
dependencies = result['dependencies']
print(f"\nOrganization '{org['name']}' has {len(dependencies)} dependency types")
# Example: Count total resources
total_resources = 0
for dep_type, items in dependencies.items():
if isinstance(items, list):
total_resources += len(items)
print(f"Total resources: {total_resources}")
# Example: Export to JSON
inspector.export_to_json(result, 'org_report.json')
def example_list_all_organizations():
"""Example of listing all organizations"""
AAP_URL = "https://aap.example.com"
USERNAME = "admin"
PASSWORD = "your_password"
# Create client
client = AAPClient(
base_url=AAP_URL,
username=USERNAME,
password=PASSWORD,
verify_ssl=True
)
# Get all organizations
orgs_data = client.get_organizations()
print(f"\nTotal organizations: {orgs_data['count']}")
print("\nOrganizations:")
for org in orgs_data['results']:
print(f" [{org['id']}] {org['name']}")
if __name__ == '__main__':
print("This is an example file. Modify the credentials and uncomment the function you want to test.")
print("\nAvailable examples:")
print(" 1. example_programmatic_usage() - Inspect a single organization")
print(" 2. example_list_all_organizations() - List all organizations")
# Uncomment one of these to run:
# example_programmatic_usage()
# example_list_all_organizations()