Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype ordering #694

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions up42/tasking.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tasking functionality
"""

import dataclasses
import datetime
from typing import Any, Dict, List, Literal, Optional, Union

Expand Down Expand Up @@ -198,3 +199,85 @@ def choose_feasibility(self, feasibility_id: str, accepted_option_id: str) -> di
"""
url = host.endpoint(f"/v2/tasking/feasibility/{feasibility_id}")
return self.session.patch(url=url, json={"acceptedOptionId": accepted_option_id}).json()


@dataclasses.dataclass
class FeasibilityOption:
id: str
feasibility_id: str
created_at: datetime.datetime
updated_at: datetime.datetime
description: str


class FeasibilityStudySorting:
created_at = utils.SortingField("created_at")


@dataclasses.dataclass
class FeasibilityStudy:
id: str
created_at: datetime.datetime
updated_at: datetime.datetime
decided_at: datetime.datetime
account_id: str
workspace_id: str
order_id: str # Do we need to link order here?
decision_status: FeasibilityStatus
options: list[FeasibilityOption]
decision_type: Optional[Literal["USER", "ADMIN", "API", "SYSTEM"]]
type: Literal["AUTO", "MANUAL"]
decision_option: Optional[FeasibilityOption]

def save(self):
# save if decision_option is set
...

@classmethod
def all(
cls,
id: Optional[str] = None,
workspace_id: Optional[str] = None,
order_id: Optional[str] = None,
decision_status: Optional[List[FeasibilityStatus]] = None,
sort_by: utils.SortingField = FeasibilityStudySorting.created_at.desc,
):
pass


class QuotationSorting:
created_at = utils.SortingField("createdAt")


@dataclasses.dataclass
class Quotation:
id: str
created_at: datetime.datetime
updated_at: datetime.datetime
decided_at: datetime.datetime
decision_type: Optional[Literal["USER", "ADMIN", "API", "SYSTEM"]]
account_id: str
workspace_id: str
order_id: str # Do we need to link order here?
credits_price: int
decision_status: QuotationStatus

def accept(self):
self.decision_status = "ACCEPTED"

def reject(self):
self.decision_status = "REJECTED"

def save(self):
...

@classmethod
def all(
cls,
id: Optional[str] = None,
workspace_id: Optional[str] = None,
order_id: Optional[str] = None,
decision_status: Optional[List[QuotationStatus]] = None,
sort_by: utils.SortingField = QuotationSorting.created_at.desc,
):
...