Package: infuzu-python-sdk
Clockwise Assignment Completion SDKOverviewDescriptionThis SDK provides a set of tools to manage assignments from Clockwise. Primarily, it allows you to fetch, represent, and mark assignments as complete.FeaturesInfuzu Authentication: Represents authentication credentials for Infuzu with methods for signature generation.Assignment Representation: Represents an Assignment fetched from Clockwise.Complete Assignment Representation: Represents a completed assignment in Clockwise.Fetch and Complete Assignments: Functionality to retrieve and mark assignments as complete.Setup InstructionsInstall the Package using pip:pip install infuzu-python-sdkUsageInfuzuCredentials ClassThis class is used to represent authentication credentials for Infuzu.frominfuzu.authimportInfuzuCredentialscredentials:InfuzuCredentials=InfuzuCredentials(secret_id="YOUR_SECRET_ID",secret_key="YOUR_SECRET_KEY")Methods & Classmethods:from_file(filepath: str) -> 'InfuzuCredentials': Create anInfuzuCredentialsinstance from aJSONfile.from_dict(data: dict[str, str]) -> 'InfuzuCredentials': Create anInfuzuCredentialsinstance from a dictionary.Clockwise AssignmentsWorking with Clockwise assignments involves fetching and completing tasks using theAssignmentandCompleteAssignmentclasses.Fetch an Assignmentfrominfuzu.clockwise.assignmentsimportget_assignment,Assignment# Fetch an assignment from Clockwisetry:assignment:Assignment=get_assignment(credentials)print(f"Fetched assignment:{assignment}")exceptNoContentError:print("No assignments available at the moment.")Completing an Assignmentfromdatetimeimportdatetimefrominfuzu.clockwise.assignmentsimportassignment_complete,CompleteAssignmentfrominfuzu.clockwise.errorsimportNoContentError# Mark an assignment as completetry:assignment:Assignment=get_assignment(credentials)# Placeholder start and end datetimes for the assignment executionstart_dt=datetime.utcnow()end_dt=datetime.utcnow()# Placeholder for your code to execute the assignment# -- Your code here --# You should capture the execution details and construct an APIResponse accordinglyresponse=APIResponse(...)# Replace with actual response datacomplete_assignment:CompleteAssignment=CompleteAssignment(assignment=assignment,start_datetime=start_dt,end_datetime=end_dt,response=response)assignment_complete(credentials,complete_assignment)print("Assignment marked as completed.")exceptNoContentError:print("No assignments available to complete.")Clockwise RulesThe SDK allows you to manage rules in Clockwise, including creating new rules, deleting existing ones, and retrieving execution logs.Create a Rulefrominfuzu.clockwise.rulesimportcreate_rule,Rulefrominfuzu.clockwise.utils.enums.api_callsimportHttpMethodfromdatetimeimporttimedeltarule:Rule=Rule(name="Daily Data Backup",url="https://api.yourcompany.com/data/backup",interval=timedelta(days=1),http_method=HttpMethod.POST)# Create the rule in Clockwiserule_id=create_rule(credentials,rule)print(f"Rule created with ID:{rule_id}")Delete a Rulefrominfuzu.clockwise.rulesimportdelete_rule# Delete Rule by IDrule_deleted_success=delete_rule(credentials,rule_id="123456")ifrule_deleted_success:print("Rule deleted successfully.")else:print("There was an error deleting the rule.")Get Rule Execution Logsfrominfuzu.clockwise.rulesimportget_rule_logs# Retrieve execution logs for a specific ruleexecutions=get_rule_logs(credentials,rule_id="123456")forexecutioninexecutions:print(f"Execution details:{execution}")Important NotePlease handle your credentials securely and ensure you manage exceptions when dealing with API calls.ContributingAs this is an open-source project hosted on GitHub, your contributions and improvements are welcome! Follow these general steps for contributing:Fork the Repository:
Start by forking the main repository to your personal GitHub account.Clone the Forked Repository:
Clone your forked repository to your local machine.git clone https://github.com/Infuzu/InfuzuPythonSDK.gitCreate a New Branch:
Before making any changes, create a new branch:git checkout -b feature-nameMake Your Changes:
Implement your features, enhancements, or bug fixes.Commit & Push:git add .
git commit -m "Descriptive commit message about changes"
git push origin feature-nameCreate a Pull Request (PR):
Go to your forked repository on GitHub and click the "New Pull Request" button. Make sure the base fork is the original repository, and the head fork is your repository and branch. Fill out the PR template with the necessary details.Remember to always be respectful and kind in all interactions with the community. It's all about learning, growing, and helping each other succeed!AcknowledgmentsCrafted with 💙 by Yidi Sprei for Infuzu. Kudos to all contributors and the expansive Infuzu andPythoncommunity for encouragement and motivation.