Micetro UserSession class - Platform - BlueCat Gateway - 25.3.0

Gateway Administration Guide

ft:locale
en-US
Product name
BlueCat Gateway
Version
25.3.0

class bluecat.gateway._internal.sessions.micetro.UserSession(username, unique_name='', *, api, platform=None, **_)

The structure made available to workflows providing properties and methods about the Micetro user session for a logged-in user. Instances of this class are created automatically by the platform when a user logs in. It can be utilized in workflows via g.user of type class UserSession (or the alias class MicetroUserSession when using Micetro authentication).

property authentication_host

The host portion of the authentication URL.

Return type: str | None

New in version 25.1.0.

property authentication_url

The base URL to the Micetro server Gateway is using for authentication of the session

It contains only the scheme, host, and (if explicitly specified in the configuration) port.

Return type: str

New in version 24.3.0.

property authentication_version

The base version for the authentication of the session.

Return type: str | None

New in version 25.2.0.

property is_replication_user

Indicates whether the user is authenticated with the Replication system.

Return type: bool

Returns: True if the user is authenticated via the Replication system, otherwise False

property logger

A logger that can be used to log messages which will have a context value unique to this user session. This is useful when identifying or tracing a user’s activities in logs.

Note:

In practice, this is a LoggerAdapter. As such it has a slightly more limited interface than a full-fledged logging.Logger. Do not (attempt to) change its logging level.

Return type: LoggerAdapter

property logger_context

A value included in the log messages made via the logger of this user session. It is unique to this user session as it derives from the username and the session. This is useful when identifying or tracing a user’s activities in logs.

Return type: str

property micetro_api

The structure for accessing the already authenticated Micetro API clients, provided by the platform.

Example:

from bluecat import route
from bluecat_libraries.micetro.apiv2 import Client
from flask import g, jsonify

def get_micetro_servers(client: Client):
    # Implement using Micetro REST API
    data = client.http_get("/servers", ...)
    # process data
    return data

@route(app, "/example/servers")
def get_servers():
    data = get_micetro_servers(g.user.micetro_api.v2)
    return jsonify(data)

Return type: MicetroAPI

property micetro_auth

The authentication used by the Python client to the Micetro API.

This property does not support assignment.

Return type: str

property micetro_url

The base URL to the Micetro server the session is for.

It contains only the scheme, host, and (if explicitly specified in the configuration) port.

Return type: str

property session_auth

The authentication value identifying this user session in Gateway.

This property does not support assignment.

Return type: str

property username

The username of the currently logged-in user.

This property does not support assignment.

Return type: str