summaryrefslogtreecommitdiff
path: root/tools/libgithub/view.py
diff options
context:
space:
mode:
authorPheenoh <pheenoh@gmail.com>2023-08-09 16:27:37 -0600
committerGitHub <noreply@github.com>2023-08-09 16:27:37 -0600
commit244892aeb849a9ad9801aa9828e6282d29df87f0 (patch)
treed0068b429e5b5ac45d2b62c8bc48509df41da204 /tools/libgithub/view.py
parentbb546a286f8c6f18c5fb1da152a34a82d17dbbaa (diff)
Github Projects (#1872)
* github projects * add project prefixes
Diffstat (limited to 'tools/libgithub/view.py')
-rw-r--r--tools/libgithub/view.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/libgithub/view.py b/tools/libgithub/view.py
new file mode 100644
index 0000000000..f01abe8bde
--- /dev/null
+++ b/tools/libgithub/view.py
@@ -0,0 +1,51 @@
+# This is mostly useless until Github extends their API to allow for view creation.
+
+from .graphql import GraphQLClient
+from dataclasses import dataclass
+from logger import LOG
+
+@dataclass
+class View:
+ def set_layoutout(self, layout: str):
+ self.layout = layout
+
+ # Doesn't actually work (yet)
+ def check_and_create(self):
+ LOG.debug(f'Checking if view {self.name} exists')
+ query = '''
+ query ($projectNumber: String!) {
+ node(id: $projectNumber) {
+ ... on ProjectV2 {
+ views {
+ nodes {
+ name
+ number
+ }
+ }
+ }
+ }
+ }
+ '''
+
+ variables = {
+ "projectNumber": self.number
+ }
+
+ data = GraphQLClient.get_instance().make_request(query, variables)
+ if data:
+ views = data['data']['node']['views']['nodes']
+ LOG.info(f'Views: {views}')
+
+ for view in views:
+ if view['name'] == self.name:
+ LOG.info(f'View {self.name} exists')
+ return
+
+ LOG.info(f'View {self.name} does not exist, creating')
+ self.create()
+ else:
+ LOG.warning(f'No views found for project {self.number}')
+
+ # Waiting on Github to update their API
+ def create(self):
+ pass \ No newline at end of file