Source code for q2_sdk.hq.db.password_history

from argparse import _SubParsersAction
from functools import partial
from typing import List
from lxml.objectify import IntElement, StringElement
from q2_sdk.core.dynamic_imports import (
    api_ExecuteStoredProcedure as ExecuteStoredProcedure,
)
from q2_sdk.hq.models.hq_params.stored_procedure import Param
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase

D_TYPES = ExecuteStoredProcedure.DataType


[docs] class PasswordHistoryRow(RepresentationRowBase): LoginName: StringElement = "LoginName" UserLogonID: IntElement = "UserLogonID" PasswordHistoryID: IntElement = "PasswordHistoryID" PasswordChangedDate: StringElement = "PasswordChangedDate"
[docs] class PasswordHistory(DbObject): """ Queries Q2_PasswordHistory table for rows that match the given arguments. Gathers details on password history """ NAME = "PasswordHistory" REPRESENTATION_ROW_CLASS = PasswordHistoryRow
[docs] def add_arguments(self, parser: _SubParsersAction): subparser = parser.add_parser("get_password_history") subparser.set_defaults(parser="get") subparser.set_defaults(func=partial(self.get, serialize_for_cli=True)) subparser.add_argument("login_name", help="Q2_UserLogon.LoginName")
[docs] def get_cli_response(self, response): columns = [ "LoginName", "UserLogonID", "PasswordHistoryID", "PasswordChangedDate", ] return self.serialize_for_cli(response, columns)
[docs] async def get( self, login_name: str, serialize_for_cli=False ) -> List[PasswordHistoryRow]: params = [] Param(login_name, D_TYPES.VarChar, "login_name").add_to_param_list(params) response = await self.call_hq( "sdk_GetPasswordHistory", ExecuteStoredProcedure.SqlParameters(params) ) if serialize_for_cli: response = self.get_cli_response(response) return response