cowbird.handlers.impl.magpie ============================ .. py:module:: cowbird.handlers.impl.magpie Attributes ---------- .. autoapisummary:: cowbird.handlers.impl.magpie.LOGGER cowbird.handlers.impl.magpie.COOKIES_TIMEOUT cowbird.handlers.impl.magpie.WFS_READ_PERMISSIONS cowbird.handlers.impl.magpie.WFS_WRITE_PERMISSIONS cowbird.handlers.impl.magpie.WMS_READ_PERMISSIONS cowbird.handlers.impl.magpie.WPS_READ_PERMISSIONS cowbird.handlers.impl.magpie.WPS_WRITE_PERMISSIONS cowbird.handlers.impl.magpie.GEOSERVER_READ_PERMISSIONS cowbird.handlers.impl.magpie.GEOSERVER_WRITE_PERMISSIONS Exceptions ---------- .. autoapisummary:: cowbird.handlers.impl.magpie.MagpieHttpError Classes ------- .. autoapisummary:: cowbird.handlers.impl.magpie.Magpie Module Contents --------------- .. py:data:: LOGGER .. py:data:: COOKIES_TIMEOUT :value: 60 .. py:data:: WFS_READ_PERMISSIONS .. py:data:: WFS_WRITE_PERMISSIONS .. py:data:: WMS_READ_PERMISSIONS .. py:data:: WPS_READ_PERMISSIONS .. py:data:: WPS_WRITE_PERMISSIONS .. py:data:: GEOSERVER_READ_PERMISSIONS .. py:data:: GEOSERVER_WRITE_PERMISSIONS .. py:class:: Magpie(settings: cowbird.typedefs.SettingsType, name: str, admin_user: str, admin_password: str, **kwargs: Any) Bases: :py:obj:`cowbird.handlers.handler.Handler` Complete the Magpie's webhook call by calling Magpie temporary urls. Also keep service-shared resources in sync when permissions are updated for one of them. ** Cowbird components diagram 1.2.0 needs to be updated since Magpie can handle permissions synchronisation directly on permission update events. No need to handle them explicitly in nginx, thredds and geoserver classes. Create the magpie instance and instantiate the permission synchronizer that will handle the permission events. :param settings: Cowbird settings for convenience :param name: Handler name :param admin_user: Magpie admin username used for login. :param admin_password: Magpie admin password used for login. .. py:attribute:: required_params .. py:attribute:: headers .. py:attribute:: admin_user .. py:attribute:: admin_password .. py:attribute:: service_types :value: None .. py:attribute:: cookies :value: None .. py:attribute:: last_cookies_update_time :value: None .. py:attribute:: permissions_synch .. py:method:: _send_request(method: str, url: str, params: Optional[Any] = None, json: Optional[Any] = None) -> requests.Response Wrapping function to send requests to Magpie, which also handles login and cookies. .. py:method:: get_service_types() -> List[str] Returns the list of service types available on Magpie. .. py:method:: get_services_by_type(service_type: str) -> Dict[str, cowbird.typedefs.JSON] .. py:method:: get_service_info(service_name: str) -> Dict[str, cowbird.typedefs.JSON] .. py:method:: get_resources_by_service(service_name: str) -> Dict[str, cowbird.typedefs.JSON] .. py:method:: get_parents_resource_tree(resource_id: int) -> List[cowbird.typedefs.JSON] Returns the associated Magpie Resource object and all its parents in a list ordered from parent to child. .. py:method:: get_resource(resource_id: int) -> Dict[str, cowbird.typedefs.JSON] Returns the associated Magpie Resource object. .. py:method:: get_geoserver_workspace_res_id(workspace_name: str, create_if_missing: Optional[bool] = False) -> Optional[int] Finds the resource id of a workspace resource from the `geoserver` type services. .. py:method:: get_geoserver_layer_res_id(workspace_name: str, layer_name: str, create_if_missing: bool = False) -> int Tries to get the resource id of a specific layer, on `geoserver` type services, and if requested, creates the resource and workspace if they do not exist yet. .. py:method:: get_user_list() -> List[str] Returns the list of all Magpie usernames. .. py:method:: get_user_id_from_user_name(user_name: str) -> int Finds the id of a user from his username. .. py:method:: get_user_name_from_user_id(user_id: int) -> str Finds the name of a user from his user id. .. py:method:: get_user_permissions(user: str) -> Dict[str, cowbird.typedefs.JSON] Gets all user resource permissions. .. py:method:: get_user_permissions_by_res_id(user: str, res_id: int, effective: bool = False) -> Dict[str, cowbird.typedefs.JSON] .. py:method:: get_user_names_by_group_name(grp_name: str) -> List[str] Returns the list of Magpie usernames from a group. .. py:method:: get_group_permissions(grp: str) -> Dict[str, cowbird.typedefs.JSON] Gets all group resource permissions. .. py:method:: get_group_permissions_by_res_id(grp: str, res_id: int, effective: bool = False) -> Dict[str, cowbird.typedefs.JSON] .. py:method:: user_created(user_name: str) -> None .. py:method:: user_deleted(user_name: str) -> None .. py:method:: permission_created(permission: magpie.permissions.Permission) -> None .. py:method:: permission_deleted(permission: magpie.permissions.Permission) -> None .. py:method:: resync() -> None .. py:method:: create_permissions(permissions_data: List[cowbird.typedefs.PermissionConfigItemType]) -> None Make sure that the specified permissions exist on Magpie. .. py:method:: create_permission_by_res_id(res_id: int, perm_name: str, perm_access: str, perm_scope: str, user_name: Optional[str] = '', grp_name: Optional[str] = '') -> Union[pyramid.response.Response, None] .. py:method:: create_permission_by_user_and_res_id(user_name: str, res_id: int, perm_name: str, perm_access: str, perm_scope: str) -> Union[pyramid.response.Response, None] .. py:method:: create_permission_by_grp_and_res_id(grp_name: str, res_id: int, perm_name: str, perm_access: str, perm_scope: str) -> Union[pyramid.response.Response, None] .. py:method:: delete_permission_by_user_and_res_id(user_name: str, res_id: int, permission_name: str) -> None .. py:method:: delete_permission_by_grp_and_res_id(grp_name: str, res_id: int, permission_name: str) -> None .. py:method:: delete_permission(permissions_data: List[Dict[str, str]]) -> None Remove the specified permission from Magpie if it exists. .. py:method:: create_resource(resource_name: str, resource_type: str, parent_id: Optional[int], resource_display_name: Optional[str] = None) -> int Creates the specified resource in Magpie and returns the created resource id if successful. .. py:method:: delete_resource(resource_id: int) -> None .. py:method:: login() -> requests.cookies.RequestsCookieJar Login to Magpie app using admin credentials. .. py:exception:: MagpieHttpError Bases: :py:obj:`Exception` Exception related to http requests done by the Magpie handler. Initialize self. See help(type(self)) for accurate signature.