|
| 1 | +# |
| 2 | +# Copyright (c) 2025 NSONE, Inc. |
| 3 | +# |
| 4 | +# License under The MIT License (MIT). See LICENSE in project root. |
| 5 | +# |
| 6 | + |
| 7 | +from ns1 import NS1 |
| 8 | +import datetime |
| 9 | + |
| 10 | +# NS1 will use config in ~/.nsone by default |
| 11 | +api = NS1() |
| 12 | + |
| 13 | +# to specify an apikey here instead, use: |
| 14 | + |
| 15 | +# from ns1 import Config |
| 16 | +# config = Config() |
| 17 | +# config.createFromAPIKey('<<CLEARTEXT API KEY>>') |
| 18 | +# api = NS1(config=config) |
| 19 | + |
| 20 | +config = api.config |
| 21 | + |
| 22 | +from_unix = int( |
| 23 | + datetime.datetime.fromisoformat("2025-02-01 00:00:00").strftime("%s") |
| 24 | +) |
| 25 | +to_unix = int( |
| 26 | + datetime.datetime.fromisoformat("2025-02-28 23:59:59").strftime("%s") |
| 27 | +) |
| 28 | + |
| 29 | +############################ |
| 30 | +# GET BILLING USAGE LIMITS # |
| 31 | +############################ |
| 32 | + |
| 33 | +limits = api.billing_usage().getLimits(from_unix, to_unix) |
| 34 | +print("### USAGE LIMITS ###") |
| 35 | +print(limits) |
| 36 | +print("####################") |
| 37 | + |
| 38 | +################################### |
| 39 | +# GET BILLING USAGE FOR QUERIES # |
| 40 | +################################### |
| 41 | + |
| 42 | +usg = api.billing_usage().getQueriesUsage(from_unix, to_unix) |
| 43 | +print("### QUERIES USAGE ###") |
| 44 | +print(usg) |
| 45 | +print("####################") |
| 46 | + |
| 47 | +################################### |
| 48 | +# GET BILLING USAGE FOR DECISIONS # |
| 49 | +################################### |
| 50 | + |
| 51 | +usg = api.billing_usage().getDecisionsUsage(from_unix, to_unix) |
| 52 | +print("### DECISIONS USAGE ###") |
| 53 | +print(usg) |
| 54 | +print("####################") |
| 55 | + |
| 56 | +################################### |
| 57 | +# GET BILLING USAGE FOR MONITORS # |
| 58 | +################################### |
| 59 | + |
| 60 | +usg = api.billing_usage().getMonitorsUsage() |
| 61 | +print("### MONITORS USAGE ###") |
| 62 | +print(usg) |
| 63 | +print("####################") |
| 64 | + |
| 65 | +################################### |
| 66 | +# GET BILLING USAGE FOR FILER CHAINS # |
| 67 | +################################### |
| 68 | + |
| 69 | +usg = api.billing_usage().getMonitorsUsage() |
| 70 | +print("### FILTER CHAINS USAGE ###") |
| 71 | +print(usg) |
| 72 | +print("####################") |
| 73 | + |
| 74 | +################################### |
| 75 | +# GET BILLING USAGE FOR RECORDS # |
| 76 | +################################### |
| 77 | + |
| 78 | +usg = api.billing_usage().getRecordsUsage() |
| 79 | +print("### RECORDS USAGE ###") |
| 80 | +print(usg) |
| 81 | +print("####################") |
0 commit comments