2 File in charge of tracking secrets for a given check
5from typing
import Dict, Any
6from datetime
import datetime, timezone
7from .variables
import Variables
12 This class is in charge of storing the secrets for the server.
15 def __init__(self, success: int = 0, error: int = 84, debug: bool =
False) ->
None:
17 Class in charge of managing the secrets for the server runtime trigger and consequences.
20 success (int, optional): _description_. Defaults to 0.
21 error (int, optional): _description_. Defaults to 84.
22 debug (bool, optional): _description_. Defaults to False.
35 def get_secret(self, secret_name: str) -> Dict[str, Any]:
37 Get the secret from the server.
40 secret_name (str): _description_
43 Dict[str, Any]: _description_
45 return self.
vars.get_variable(secret_name, self.
scope)
49 Set the token for the server.
52 token (str): _description_
54 self.
vars.insert_or_update(
"token", token, type(token), self.
scope)
55 bearer = f
"Bearer {token}"
56 self.
vars.insert_or_update(
"bearer", bearer, type(bearer), self.
scope)
60 Get the token for the server.
65 return self.
vars.get_variable(
"token", self.
scope)
69 Get the bearer for the server.
74 return self.
vars.get_variable(
"bearer", self.
scope)
81 return datetime.now().isoformat()
86 $ref{secrets.current_date}: Returns the current date without the time in the server's local timezone
91 return datetime.now().date().isoformat()
96 $ref{secrets.current_time}: Returns the current time (hours:minutes:seconds) in the server's local timezone
101 return datetime.now().time().replace(microsecond=0).isoformat()
106 $ref{secrets.now_utc}: Returns the current datetime in UTC with timezone info
109 _type_: _description_
111 return datetime.now(timezone.utc).isoformat()
116 $ref{secrets.current_date_utc}: Returns the current date without the time in UTC
119 _type_: _description_
121 return datetime.now(timezone.utc).date().isoformat()
126 $ref{secrets.current_time_utc}: Returns the current time (hours:minutes:seconds) in UTC
129 _type_: _description_
131 return datetime.now(timezone.utc).time().replace(microsecond=0).isoformat()
136 $ref{secrets.now_server}: Returns the current datetime with timezone info in the server's local timezone
139 _type_: _description_
141 return datetime.now().astimezone().isoformat()
146 $ref{secrets.current_date_server}: Returns the current date without the time in the server's local timezone
149 _type_: _description_
151 return datetime.now().astimezone().date().isoformat()
156 $ref{secrets.current_time_server}: Returns the current time (hours:minutes:seconds) in the server's local timezone
159 _type_: _description_
161 return datetime.now().astimezone().time().replace(microsecond=0).isoformat()
str current_date_server()
None __init__(self, int success=0, int error=84, bool debug=False)
Dict[str, Any] get_secret(self, str secret_name)
None set_token(self, str token)
str current_time_server()