|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from datetime import datetime |
| 4 | +from typing import TYPE_CHECKING, Any |
| 5 | + |
| 6 | +import github.AdvisoryVulnerabilityPackage |
| 7 | +import github.DependabotAlertAdvisory |
| 8 | +import github.DependabotAlertDependency |
| 9 | +import github.DependabotAlertVulnerability |
| 10 | +import github.NamedUser |
| 11 | +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet |
| 12 | + |
| 13 | +if TYPE_CHECKING: |
| 14 | + from github.DependabotAlertAdvisory import DependabotAlertAdvisory |
| 15 | + from github.DependabotAlertDependency import DependabotAlertDependency |
| 16 | + from github.DependabotAlertVulnerability import DependabotAlertVulnerability |
| 17 | + from github.NamedUser import NamedUser |
| 18 | + |
| 19 | + |
| 20 | +class DependabotAlert(NonCompletableGithubObject): |
| 21 | + """ |
| 22 | + This class represents a DependabotAlert. |
| 23 | + The reference can be found here https://docs.github.com/en/rest/dependabot/alerts |
| 24 | + """ |
| 25 | + |
| 26 | + def _initAttributes(self) -> None: |
| 27 | + self._number: Attribute[int] = NotSet |
| 28 | + self._state: Attribute[str] = NotSet |
| 29 | + self._dependency: Attribute[DependabotAlertDependency] = NotSet |
| 30 | + self._security_advisory: Attribute[DependabotAlertAdvisory] = NotSet |
| 31 | + self._security_vulnerability: Attribute[DependabotAlertVulnerability] = NotSet |
| 32 | + self._url: Attribute[str] = NotSet |
| 33 | + self._html_url: Attribute[str] = NotSet |
| 34 | + self._created_at: Attribute[datetime] = NotSet |
| 35 | + self._updated_at: Attribute[datetime] = NotSet |
| 36 | + self._dismissed_at: Attribute[datetime | None] = NotSet |
| 37 | + self._dismissed_by: Attribute[NamedUser | None] = NotSet |
| 38 | + self._dismissed_reason: Attribute[str | None] = NotSet |
| 39 | + self._dismissed_comment: Attribute[str | None] = NotSet |
| 40 | + self._fixed_at: Attribute[str] = NotSet |
| 41 | + |
| 42 | + def __repr__(self) -> str: |
| 43 | + return self.get__repr__({"number": self.number, "ghsa_id": self.security_advisory.ghsa_id}) |
| 44 | + |
| 45 | + @property |
| 46 | + def number(self) -> int: |
| 47 | + return self._number.value |
| 48 | + |
| 49 | + @property |
| 50 | + def state(self) -> str: |
| 51 | + return self._state.value |
| 52 | + |
| 53 | + @property |
| 54 | + def dependency(self) -> DependabotAlertDependency: |
| 55 | + return self._dependency.value |
| 56 | + |
| 57 | + @property |
| 58 | + def security_advisory(self) -> DependabotAlertAdvisory: |
| 59 | + return self._security_advisory.value |
| 60 | + |
| 61 | + @property |
| 62 | + def security_vulnerability(self) -> DependabotAlertVulnerability: |
| 63 | + return self._security_vulnerability.value |
| 64 | + |
| 65 | + @property |
| 66 | + def url(self) -> str: |
| 67 | + return self._url.value |
| 68 | + |
| 69 | + @property |
| 70 | + def html_url(self) -> str: |
| 71 | + return self._html_url.value |
| 72 | + |
| 73 | + @property |
| 74 | + def created_at(self) -> datetime: |
| 75 | + return self._created_at.value |
| 76 | + |
| 77 | + @property |
| 78 | + def updated_at(self) -> datetime: |
| 79 | + return self._updated_at.value |
| 80 | + |
| 81 | + @property |
| 82 | + def dismissed_at(self) -> datetime | None: |
| 83 | + return self._dismissed_at.value |
| 84 | + |
| 85 | + @property |
| 86 | + def dismissed_by(self) -> NamedUser | None: |
| 87 | + return self._dismissed_by.value |
| 88 | + |
| 89 | + @property |
| 90 | + def dismissed_reason(self) -> str | None: |
| 91 | + return self._dismissed_reason.value |
| 92 | + |
| 93 | + @property |
| 94 | + def dismissed_comment(self) -> str | None: |
| 95 | + return self._dismissed_comment.value |
| 96 | + |
| 97 | + @property |
| 98 | + def fixed_at(self) -> str | None: |
| 99 | + return self._fixed_at.value |
| 100 | + |
| 101 | + def _useAttributes(self, attributes: dict[str, Any]) -> None: |
| 102 | + if "number" in attributes: |
| 103 | + self._number = self._makeIntAttribute(attributes["number"]) |
| 104 | + if "state" in attributes: |
| 105 | + self._state = self._makeStringAttribute(attributes["state"]) |
| 106 | + if "dependency" in attributes: |
| 107 | + self._dependency = self._makeClassAttribute( |
| 108 | + github.DependabotAlertDependency.DependabotAlertDependency, attributes["dependency"] |
| 109 | + ) |
| 110 | + if "security_advisory" in attributes: |
| 111 | + self._security_advisory = self._makeClassAttribute( |
| 112 | + github.DependabotAlertAdvisory.DependabotAlertAdvisory, attributes["security_advisory"] |
| 113 | + ) |
| 114 | + if "security_vulnerability" in attributes: |
| 115 | + self._security_vulnerability = self._makeClassAttribute( |
| 116 | + github.DependabotAlertVulnerability.DependabotAlertVulnerability, attributes["security_vulnerability"] |
| 117 | + ) |
| 118 | + if "url" in attributes: |
| 119 | + self._url = self._makeStringAttribute(attributes["url"]) |
| 120 | + if "html_url" in attributes: |
| 121 | + self._html_url = self._makeStringAttribute(attributes["html_url"]) |
| 122 | + if "created_at" in attributes: |
| 123 | + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) |
| 124 | + if "updated_at" in attributes: |
| 125 | + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) |
| 126 | + if "dismissed_at" in attributes: |
| 127 | + self._dismissed_at = self._makeDatetimeAttribute(attributes["dismissed_at"]) |
| 128 | + if "dismissed_by" in attributes: |
| 129 | + self._dismissed_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["dismissed_by"]) |
| 130 | + if "dismissed_reason" in attributes: |
| 131 | + self._dismissed_reason = self._makeStringAttribute(attributes["dismissed_reason"]) |
| 132 | + if "dismissed_comment" in attributes: |
| 133 | + self._dismissed_comment = self._makeStringAttribute(attributes["dismissed_comment"]) |
| 134 | + if "fixed_at" in attributes: |
| 135 | + self._fixed_at = self._makeStringAttribute(attributes["fixed_at"]) |
0 commit comments