-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from cedarville-university/develop
Summer 2024 Release PR
- Loading branch information
Showing
5 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import json | ||
from typing import Optional | ||
from enum import Enum | ||
import tdxlib.tdx_api_exceptions | ||
import tdxlib.tdx_utils | ||
import datetime | ||
from typing_extensions import TypedDict | ||
import json | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
import tdxlib.tdx_report_integration | ||
|
||
class OrderByColumn(TypedDict): | ||
ColumnLabel: str | ||
ColumnName: str | ||
IsAscending: bool | ||
class ChartSetting(TypedDict): | ||
Axis: Optional[str] | ||
ColumnLabel: Optional[str] | ||
ColumnName: Optional[str] | ||
class ColumnDataType(Enum): | ||
GenericData = 0 | ||
String = 1 | ||
Integer = 2 | ||
Decimal = 3 | ||
Currency = 4 | ||
Percentage = 5 | ||
Date = 6 | ||
DateAndTime = 7 | ||
Boolean = 8 | ||
TimeSpan = 9 | ||
ProjectHealth = 10 | ||
Html = 11 | ||
class AggregateFunction(Enum): | ||
NONE = 0 | ||
Average = 1 | ||
Count = 2 | ||
Maximum = 3 | ||
Minimum = 4 | ||
Sum = 5 | ||
class ComponentFunction(Enum): | ||
NONE = 0 | ||
Year = 1 | ||
MonthYear = 2 | ||
WeekYear = 3 | ||
Hour = 4 | ||
HourWeek = 5 | ||
HourMonth = 6 | ||
class DisplayColumn(TypedDict): | ||
HeaderText: str | ||
ColumnName: str | ||
DataType: ColumnDataType | ||
SortColumnExpression: Optional[str] | ||
SortColumnName: Optional[str] | ||
SortDataType: ColumnDataType | ||
Aggregate: AggregateFunction | ||
Component: ComponentFunction | ||
FooterExpression: Optional[str] | ||
class TDXReportData(TypedDict): | ||
Description: Optional[str] | ||
MaxResults: int | ||
DisplayedColumns: Optional[list[DisplayColumn]] | ||
SortOrder: Optional[list[OrderByColumn]] | ||
ChartType: Optional[str] | ||
ChartSettings: Optional[list[ChartSetting]] | ||
DataRows: Optional[list[dict[str, object]]] | ||
ID: int | ||
Name: str | ||
CreatedUid: Optional[str] | ||
CreatedFullName: str | ||
CreatedDate: datetime.datetime | ||
OwningGroupID: Optional[int] | ||
OwningGroupName: str | ||
SystemAppName: str | ||
PlatformAppID: int | ||
PlatformAppName: Optional[str] | ||
ReportSourceID: int | ||
ReportSourceName: str | ||
Uri: str | ||
class TDXReport(TypedDict): | ||
report_data: TDXReportData | ||
tdx_api: 'tdxlib.tdx_report_integration.TDXReportIntegration' | ||
def __repr__(self): | ||
return str(self.report_data.__dict__) | ||
|
||
def __str__(self): | ||
return json.dumps(self) | ||
|
||
def __init__(self, integration: 'tdxlib.tdx_report_integration.TDXReportIntegration', json: str): | ||
self.tdx_api = integration | ||
self.report_data = json.loads(json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import tdxlib.tdx_report | ||
import copy | ||
import datetime | ||
from tdxlib.tdx_integration import TDXIntegration | ||
import tdxlib.tdx_api_exceptions | ||
from typing import Union | ||
from typing import BinaryIO | ||
import json | ||
|
||
class TDXReportIntegration(TDXIntegration): | ||
def __init__(self, filename: str = None, config=None): | ||
tdxlib.tdx_integration.TDXIntegration.__init__(self, filename, config) | ||
self.clean_cache() | ||
def make_report_call(self, url: str, action: str, post_body: dict = None): | ||
url_string = '/reports' | ||
if len(url) > 0: | ||
url_string += '/' + url | ||
if action == 'get': | ||
return self.make_get(url_string) | ||
if action == 'delete': | ||
return self.make_delete(url_string) | ||
if action == 'post' and post_body: | ||
return self.make_post(url_string, post_body) | ||
if action == 'put' and post_body: | ||
return self.make_put(url_string, post_body) | ||
if action == 'patch' and post_body: | ||
return self.make_patch(url_string, post_body) | ||
raise tdxlib.tdx_api_exceptions.TdxApiHTTPRequestError('No method ' + action + ' or no post information') | ||
def get_report_by_id(self, id: int, withData: bool = False, dataSortExpression: str = "") -> tdxlib.tdx_report.TDXReport: | ||
url_string = f"{id}?withData={withData}&dataSortExpression={dataSortExpression}" | ||
report_data = self.make_report_call(url_string, 'get') | ||
if report_data: | ||
#return tdxlib.tdx_report.TDXReport.__init__(integration=self, json=report_data) | ||
result: tdxlib.tdx_report.TDXReport = { | ||
'report_data': report_data, | ||
'tdx_api': self | ||
} | ||
return result |