Coretex
coretex.entities.secret.secret.Secret Class Reference
Inheritance diagram for coretex.entities.secret.secret.Secret:
coretex.entities.secret.aws_secret.AWSSecret coretex.entities.secret.credentials.CredentialsSecret coretex.entities.secret.git_secret.GitSecret coretex.entities.secret.project_secret.ProjectSecret

Public Member Functions

Self decrypted (self, Optional[RSAPrivateKey] key=None)
 
bool refresh (self, Optional[Dict[str, Any]] jsonObject=None)
 
bool update (self, **Any kwargs)
 
Self fetchById (cls, int objectId, **Any kwargs)
 
Self fetchByName (cls, str name)
 
Self fetchNodeSecret (cls, str name, str accessToken)
 

Detailed Description

    Represents base Secret entity from Coretex.ai

Definition at line 32 of file secret.py.

Member Function Documentation

◆ decrypted()

Self coretex.entities.secret.secret.Secret.decrypted (   self,
Optional[RSAPrivateKey]   key = None 
)
    Returns
    -------
    Self -> Decrypted Coretex Secret

Definition at line 54 of file secret.py.

54  def decrypted(self, key: Optional[RSAPrivateKey] = None) -> Self:
55  """
56  Returns
57  -------
58  Self -> Decrypted Coretex Secret
59  """
60 
61  if key is None:
62  key = rsa.getPrivateKey()
63 
64  decrypted = copy.deepcopy(self)
65 
66  for field in self._encryptedFields():
67  if not field in decrypted.__dict__:
68  raise AttributeError(f"\"{type(decrypted)}\".\"{field}\" not found")
69 
70  value = decrypted.__dict__[field]
71  if not isinstance(value, str):
72  raise TypeError(f"Expected \"str\" received \"{type(value)}\"")
73 
74  decrypted.__dict__[field] = rsa.decrypt(key, b64decode(value)).decode("utf-8")
75 
76  return decrypted
77 

◆ fetchById()

Self coretex.entities.secret.secret.Secret.fetchById (   cls,
int  objectId,
**Any  kwargs 
)
    Secret does not support this method

Definition at line 97 of file secret.py.

97  def fetchById(cls, objectId: int, **kwargs: Any) -> Self:
98  """
99  Secret does not support this method
100  """
101 
102  return NotImplemented
103 

◆ fetchByName()

Self coretex.entities.secret.secret.Secret.fetchByName (   cls,
str  name 
)
    Fetches a single Secret with the matching name

    Parameters
    ----------
    name : str
        name of the Secret which is fetched

    Returns
    -------
    Self -> fetched Secret

    Raises
    ------
    NetworkRequestError -> If the request for fetching failed

Definition at line 105 of file secret.py.

105  def fetchByName(cls, name: str) -> Self:
106  """
107  Fetches a single Secret with the matching name
108 
109  Parameters
110  ----------
111  name : str
112  name of the Secret which is fetched
113 
114  Returns
115  -------
116  Self -> fetched Secret
117 
118  Raises
119  ------
120  NetworkRequestError -> If the request for fetching failed
121  """
122 
123  response = networkManager.get(f"{cls._endpoint()}/data", {
124  "name": name
125  })
126 
127  if response.hasFailed():
128  raise NetworkRequestError(response, f"Failed to fetch Secret \"{name}\"")
129 
130  return cls.decode(response.getJson(dict))
131 

◆ fetchNodeSecret()

Self coretex.entities.secret.secret.Secret.fetchNodeSecret (   cls,
str  name,
str  accessToken 
)
    Fetches a single Node Secret with the matching name

    Parameters
    ----------
    name : str
        name of the Node Secret which is fetched
    accessToken : str
        Node access token

    Returns
    -------
    Self -> fetched Node Secret

    Raises
    ------
    NetworkRequestError -> If the request for fetching failed

Definition at line 133 of file secret.py.

133  def fetchNodeSecret(cls, name: str, accessToken: str) -> Self:
134  """
135  Fetches a single Node Secret with the matching name
136 
137  Parameters
138  ----------
139  name : str
140  name of the Node Secret which is fetched
141  accessToken : str
142  Node access token
143 
144  Returns
145  -------
146  Self -> fetched Node Secret
147 
148  Raises
149  ------
150  NetworkRequestError -> If the request for fetching failed
151  """
152 
153  headers = networkManager._headers()
154  headers["node-access-token"] = accessToken
155 
156  response = networkManager.request("secret/node", RequestType.get, headers, {
157  "name": name
158  })
159 
160  if response.hasFailed():
161  raise NetworkRequestError(response, f"Failed to fetch Node Secret \"{name}\"")
162 
163  return cls.decode(response.getJson(dict))

◆ refresh()

bool coretex.entities.secret.secret.Secret.refresh (   self,
Optional[Dict[str, Any]]   jsonObject = None 
)
    Secret does not support this method

Definition at line 82 of file secret.py.

82  def refresh(self, jsonObject: Optional[Dict[str, Any]] = None) -> bool:
83  """
84  Secret does not support this method
85  """
86 
87  return NotImplemented
88 

◆ update()

bool coretex.entities.secret.secret.Secret.update (   self,
**Any  kwargs 
)
    Secret does not support this method

Definition at line 89 of file secret.py.

89  def update(self, **kwargs: Any) -> bool:
90  """
91  Secret does not support this method
92  """
93 
94  return NotImplemented
95 

The documentation for this class was generated from the following file: