Tempo

The TempoWrapper class facilitates interaction with the Tempo API through HTTP requests. It includes attributes for the API token and version, along with methods for setting the token, generating HTTP headers, and executing GET, POST, PUT, and DELETE requests to specified endpoints.

By encapsulating the logic for handling API authentication and requests, developers can seamlessly integrate Tempo functionality into their applications while adhering to proper authentication protocols and API conventions.

Usage

Below there are some examples of usage.

# Initialize TempoWrapper with the access token tempo_wrapper = TempoWrapper(api_token="YOUR_ACCESS_TOKEN") # Example: Accounts # Get all accounts response = tempo_wrapper.get("/accounts") if response.status_code == 200: all_accounts = response.json() print("All accounts:", all_accounts) else: print("Failed to retrieve accounts. Status code:", response.status_code) # Example: Account - Categories # Get all account categories response = tempo_wrapper.get("/account-categories") if response.status_code == 200: all_categories = response.json() print("All categories:", all_categories) else: print("Failed to retrieve categories. Status code:", response.status_code) # Example: Account - Category - Types # Get all account category types response = tempo_wrapper.get("/account-category-types") if response.status_code == 200: all_category_types = response.json() print("All category types:", all_category_types) else: print("Failed to retrieve category types. Status code:", response.status_code) # Example: Account - Links # Get account links response = tempo_wrapper.get("/account-links") if response.status_code == 200: account_links = response.json() print("Account links:", account_links) else: print("Failed to retrieve account links. Status code:", response.status_code) # Example: Customers # Get all customers response = tempo_wrapper.get("/customers") if response.status_code == 200: all_customers = response.json() print("All customers:", all_customers) else: print("Failed to retrieve customers. Status code:", response.status_code) # Example: Generic Resources # Add a new generic resource data = { "name": "New Resource", "type": "Resource Type", "capacity": 8 } response = tempo_wrapper.post("/generic-resources", data=data) if response.status_code == 200: new_resource = response.json() print("New resource added:", new_resource) else: print("Failed to add resource. Status code:", response.status_code) # Example: Global Configuration # Get global configuration response = tempo_wrapper.get("/globalconfiguration") if response.status_code == 200: global_config = response.json() print("Global configuration:", global_config) else: print("Failed to retrieve global configuration. Status code:", response.status_code) # Example: Holiday Schemes # Get all holiday schemes response = tempo_wrapper.get("/holiday-schemes") if response.status_code == 200: holiday_schemes = response.json() print("All holiday schemes:", holiday_schemes) else: print("Failed to retrieve holiday schemes. Status code:", response.status_code) # Example: Periods # Get all periods response = tempo_wrapper.get("/periods") if response.status_code == 200: periods = response.json() print("All periods:", periods) else: print("Failed to retrieve periods. Status code:", response.status_code) # Example: Permission Roles # Get all permission roles response = tempo_wrapper.get("/permission-roles") if response.status_code == 200: permission_roles = response.json() print("All permission roles:", permission_roles) else: print("Failed to retrieve permission roles. Status code:", response.status_code) # Example: Plans # Get all plans response = tempo_wrapper.get("/plans") if response.status_code == 200: plans = response.json() print("All plans:", plans) else: print("Failed to retrieve plans. Status code:", response.status_code) response = tempo_wrapper.get("/programs") if response.status_code == 200: programs = response.json() print("All programs:", programs) else: print("Failed to retrieve programs. Status code:", response.status_code) # Example: Roles # Get all roles response = tempo_wrapper.get("/roles") if response.status_code == 200: roles = response.json() print("All roles:", roles) else: print("Failed to retrieve roles. Status code:", response.status_code) # Example: Teams # Get all teams response = tempo_wrapper.get("/teams") if response.status_code == 200: teams = response.json() print("All teams:", teams) else: print("Failed to retrieve teams. Status code:", response.status_code)

Easy for Jira - Python Automations, 2023