ManagementService.ManagementAPI package
Submodules
ManagementService.ManagementAPI.app module
ManagementService.ManagementAPI.config module
ManagementService.ManagementAPI.example module
ManagementService.ManagementAPI.managementservice module
ManagementService.ManagementAPI.service module
- class ManagementService.ManagementAPI.service.Service(*args, **kwargs)
Bases:
object- init_model(tables)
- static init_orm(model_config)
- query_api(api_name, request_method, request_params={}, headers=None, body=None)
method used for api queries — api_name: registered api name in api_config request_method: “get”, “post”, “put”, “delete” request_params: request parameters headers: request headers body: request body — USAGE: api_config = { “api_name1”: “http:api1:5000/path/to/api”, “api_name2”: “http:api2:5000/path/to/api”, }
- query_db(query, args=(), retval=False)
method used for sql database queries — query: sql query args: sql query arguments retval: True for SELECT | FALSE for INSERT, DELETE, etc
- query_model(model_name)
Method used for orm database queries — USAGE: with self.query_model(<TABLE NAME>) as (conn, <TABLE>):
res = conn.execute(…)
— model_name: table name
- ManagementService.ManagementAPI.service.default_validator(col_type, val)
- ManagementService.ManagementAPI.service.insert_into_dict(dest, keys, vals)
- ManagementService.ManagementAPI.service.validate(self, data, optional=False, drop=False, exclude=[])
Validator method for request body. Injected into sqlalchemy Model. — USAGE: with self.query_model(<TABLE NAME>) as (conn, <TABLE>):
verified_json_body, status = <TABLE>.validate(<REQUEST BODY>) if status:
# validation success
- else:
# validation fail
— data: json dict — Returns dict of validated values mapped to model.
- ManagementService.ManagementAPI.service.validator(*args)
Decorator which decorates validation functions. — USAGE:
# single value validator @validator(“Reservation.user”) def reservation_date_validator(user): # example validator
- if user is cond:
return True
return False
# multiple value validator @validator(“Reservation.start_date”, “Reservation.end_date”) def reservation_date_validator(start_date, end_date): # example validator
- if start_date is cond and end_date is cond:
return True
return False
ManagementService.ManagementAPI.utils module
- ManagementService.ManagementAPI.utils.check_if_room_identical(conn, Room, valid_data)
This function checks if a room in a database is identical to valid data based on its name and address.
- Parameters:
conn – The database connection object used to execute SQL queries
Room – The Room parameter is likely a SQLAlchemy model class representing a table in a
database. It is used to construct SQL queries to check if a room with certain attributes already exists in the database :param valid_data: It is a dictionary containing valid data for a room, including the room name, address line 1, and address line 2 :return: a boolean value (True or False) depending on whether a room with the same name, address1, and address2 already exists in the database.
- ManagementService.ManagementAPI.utils.check_jwt_exists(auth_info)
The function checks if a JWT (JSON Web Token) exists in the given authentication information.
- Parameters:
auth_info – The auth_info parameter is a dictionary that contains information about the
authentication status of a user. The function checks if the “status” key exists in the dictionary and returns its value. If the “status” key does not exist, the function returns False :return: a boolean value. If the “status” key is not present in the dictionary passed as an argument, it returns False. Otherwise, it returns the value associated with the “status” key.
- ManagementService.ManagementAPI.utils.create_confirmation_email(reservation, room, creator, sender='', title='[회의실 예약 시스템] 회의실 예약이 취소되었습니다', template_name='template.txt')
Generates an alert email for when new reservation is created. sender: email address that sends out alert emails title: email title template_name: email body template file name
Returns a dict for POST alertservice/alert body
- ManagementService.ManagementAPI.utils.serialize(data, include=[], exclude=[])
The function serializes data by converting datetime, date, and time objects to strings.
- Parameters:
data – The data parameter is a dictionary containing the data that needs to be serialized
include – The include parameter is a list of keys that should be included in the serialized
data. If this parameter is not empty, only the keys in the list will be included in the output :param exclude: The exclude parameter is a list of keys that should be excluded from the serialized data. If a key in the exclude list is found in the data dictionary, it will not be included in the serialized_data dictionary that is returned :return: The function serialize takes in a dictionary data and two optional lists include and exclude. It serializes the data by converting any datetime, date, or time objects to strings and returns the serialized data as a dictionary.