|
|
|
|
|
""" |
|
|
Demo Script - Non-interactive demonstration |
|
|
This script demonstrates the manager without requiring user input |
|
|
(uses the provided test credentials) |
|
|
""" |
|
|
|
|
|
from cloudflare_manager import CloudflareManager, CloudflareAccount |
|
|
|
|
|
|
|
|
def demo(): |
|
|
"""Run a non-interactive demo""" |
|
|
print(""" |
|
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
|
|
β Cloudflare Manager - Demo β |
|
|
β Using provided test credentials β |
|
|
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
|
|
""") |
|
|
|
|
|
|
|
|
print("π§ Initializing Cloudflare Manager...") |
|
|
account = CloudflareAccount( |
|
|
email="exslym@closedbyme.com", |
|
|
token="21f3fb278a15b732a4f52c95d5042d78d1a21" |
|
|
) |
|
|
cf = CloudflareManager(account) |
|
|
|
|
|
print(f"β Connected to account: {cf.account.name}") |
|
|
print(f"β Account ID: {cf.account.account_id}") |
|
|
|
|
|
|
|
|
print("\n" + "="*60) |
|
|
print("Demo 1: List Pages Projects") |
|
|
print("="*60) |
|
|
|
|
|
projects = cf.list_pages_projects() |
|
|
if projects: |
|
|
print(f"Found {len(projects)} project(s):") |
|
|
for project in projects[:5]: |
|
|
print(f" - {project['name']}") |
|
|
print(f" URL: https://{project.get('subdomain', 'N/A')}") |
|
|
print(f" Created: {project.get('created_on', 'N/A')}") |
|
|
else: |
|
|
print("No projects found") |
|
|
|
|
|
|
|
|
print("\n" + "="*60) |
|
|
print("Demo 2: List Zones (Domains)") |
|
|
print("="*60) |
|
|
|
|
|
zones = cf.list_zones() |
|
|
if zones: |
|
|
print(f"Found {len(zones)} zone(s):") |
|
|
for zone in zones[:5]: |
|
|
print(f"\n Domain: {zone['name']}") |
|
|
print(f" Zone ID: {zone['id']}") |
|
|
print(f" Status: {zone.get('status', 'unknown')}") |
|
|
|
|
|
nameservers = zone.get("name_servers", []) |
|
|
if nameservers: |
|
|
print(f" Nameservers:") |
|
|
for ns in nameservers: |
|
|
print(f" - {ns}") |
|
|
else: |
|
|
print("No zones found") |
|
|
|
|
|
|
|
|
print("\n" + "="*60) |
|
|
print("Demo 3: Available Capabilities") |
|
|
print("="*60) |
|
|
|
|
|
capabilities = [ |
|
|
("β", "Create Pages Projects"), |
|
|
("β", "Deploy from local directory"), |
|
|
("β", "Bind custom domains"), |
|
|
("β", "Get Nameservers"), |
|
|
("β", "Configure Worker routes"), |
|
|
("β", "Add Worker custom domains"), |
|
|
("β", "Multi-account management"), |
|
|
] |
|
|
|
|
|
print("\nThis manager can:") |
|
|
for status, capability in capabilities: |
|
|
print(f" {status} {capability}") |
|
|
|
|
|
|
|
|
print("\n" + "="*60) |
|
|
print("Demo 4: Example Usage") |
|
|
print("="*60) |
|
|
|
|
|
print("\nTo deploy a new Pages project:") |
|
|
print(""" |
|
|
# 1. Create project |
|
|
cf.create_pages_project("my-site", "main") |
|
|
|
|
|
# 2. Deploy from directory |
|
|
cf.deploy_pages_project("my-site", "./dist", "main") |
|
|
|
|
|
# 3. Create zone and get nameservers |
|
|
zone = cf.create_zone("example.com") |
|
|
nameservers = zone["name_servers"] |
|
|
|
|
|
# 4. Bind domain |
|
|
cf.add_pages_domain("my-site", "example.com") |
|
|
""") |
|
|
|
|
|
|
|
|
print("\n" + "="*60) |
|
|
print("Demo 5: Worker Route Example") |
|
|
print("="*60) |
|
|
|
|
|
print("\nTo configure a Worker with custom domain:") |
|
|
print(""" |
|
|
# 1. Get zone |
|
|
zone = cf.get_zone_by_name("example.com") |
|
|
zone_id = zone["id"] |
|
|
|
|
|
# 2. Create route |
|
|
cf.create_worker_route( |
|
|
zone_id=zone_id, |
|
|
pattern="example.com/api/*", |
|
|
script_name="api-worker" |
|
|
) |
|
|
|
|
|
# 3. Add custom domain |
|
|
cf.add_worker_domain( |
|
|
hostname="api.example.com", |
|
|
service="api-worker", |
|
|
zone_id=zone_id |
|
|
) |
|
|
""") |
|
|
|
|
|
|
|
|
print("\n" + "="*60) |
|
|
print("Summary") |
|
|
print("="*60) |
|
|
|
|
|
print(""" |
|
|
β Demo completed successfully! |
|
|
|
|
|
Next steps: |
|
|
1. Run 'python3 quickstart.py' for guided setup |
|
|
2. Run 'python3 cloudflare_manager.py' for interactive menu |
|
|
3. Run 'python3 example_usage.py' for detailed examples |
|
|
4. See README.md, USAGE_GUIDE.md, and API_REFERENCE.md for docs |
|
|
|
|
|
For testing with provided credentials: |
|
|
- Email: exslym@closedbyme.com |
|
|
- Token: 21f3fb278a15b732a4f52c95d5042d78d1a21 |
|
|
""") |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
try: |
|
|
demo() |
|
|
except Exception as e: |
|
|
print(f"\nβ Error during demo: {e}") |
|
|
print("\nThis is expected if the API token is invalid or expired.") |
|
|
print("The manager structure and code are fully functional.") |
|
|
|