# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Get a password policy
Sample response (may differ slightly in your environment)
.. code-block:: xml
<Q2API HqVersion="4.2.3.4215A" HqAssemblyVersion="4.2.6185.31252" ServerDateTime="2017-11-28T14:45:53.4071664-06:00">
<Result>
<ErrorCode ErrorType="Success">0</ErrorCode>
<ErrorDescription/>
<HydraErrorReturnCode>0</HydraErrorReturnCode>
</Result>
<Data>
<DalPasswordPolicyByUISourceId>
<Q2_PasswordPolicyByUISourceId>
<UISourceID>1</UISourceID>
<PasswordPolicyID>1</PasswordPolicyID>
<PasswordHistoryNumber>10</PasswordHistoryNumber>
<MaxPasswordAge>90</MaxPasswordAge>
<MinPasswordAge>0</MinPasswordAge>
<MaxPasswordLength>15</MaxPasswordLength>
<MinPasswordLength>5</MinPasswordLength>
<NumbersRequired>1</NumbersRequired>
<UpperCaseRequired>0</UpperCaseRequired>
<LowerCaseRequired>0</LowerCaseRequired>
<SpecialCharRequired>0</SpecialCharRequired>
<InvalidAttempts>3</InvalidAttempts>
<InvalidAction>0</InvalidAction>
<LimitRepeating>0</LimitRepeating>
<LimitAdjacent>0</LimitAdjacent>
<ExcludeCharList/>
<AutoResetHours>24</AutoResetHours>
<NewPwdExpirationHours>72</NewPwdExpirationHours>
<CQRCount>0</CQRCount>
<CQRInvalidAttempts>3</CQRInvalidAttempts>
<CaseSensitiveAnswer>0</CaseSensitiveAnswer>
<QuestionMinLength>10</QuestionMinLength>
<AnswerMinLength>4</AnswerMinLength>
<TACRequiredLostPwd>0</TACRequiredLostPwd>
<TACTTLMinutes>0</TACTTLMinutes>
<TACDeliveryViaVoice>0</TACDeliveryViaVoice>
<TACDeliveryViaEmail>0</TACDeliveryViaEmail>
<TACLength>0</TACLength>
<Description>Internet</Description>
<LoginMinLength>1</LoginMinLength>
<LoginMaxLength>50</LoginMaxLength>
<DormantDays>0</DormantDays>
<MlaMinLength>4</MlaMinLength>
<MlaMaxLength>10</MlaMaxLength>
<MlaRequireAlpha>true</MlaRequireAlpha>
<MlaRequireNumeric>true</MlaRequireNumeric>
<TACDeliveryViaSMS>false</TACDeliveryViaSMS>
<OobInvalidAttempts>5</OobInvalidAttempts>
<OobInvalidAction>0</OobInvalidAction>
</Q2_PasswordPolicyByUISourceId>
</DalPasswordPolicyByUISourceId>
</Data>
</Q2API>
"""
from dataclasses import dataclass
from typing import List, Optional, Union
from lxml.objectify import FloatElement, StringElement, IntElement, BoolElement
from q2_sdk.core.q2_logging.logger import Q2LoggerType
from q2_sdk.hq.models.hq_response import HqResponse
from q2_sdk.hq.models.hq_credentials import HqCredentials
from q2_sdk.hq.models.hq_params.q2_api import Q2ApiParamsObj
from q2_sdk.hq.models.hq_request.q2_api import Q2ApiRequest
[docs]
class ParamsObj(Q2ApiParamsObj):
"""Parameters definition for GetPasswordPolicy"""
def __init__(
self,
logger: Q2LoggerType,
ui_source: str,
hq_credentials: Optional[HqCredentials] = None,
):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param ui_source: ShortName of Q2_UiSource row. Should almost always be OnlineBanking
:param hq_credentials: Defaults to settings.HQ_CREDENTIALS
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"UiSource": ui_source,
})
[docs]
@dataclass
class Q2_PasswordPolicyByUISourceId:
AnswerMinLength: IntElement
AutoResetHours: IntElement
CQRCount: IntElement
CQRInvalidAttempts: IntElement
CaseSensitiveAnswer: IntElement
Description: StringElement
DormantDays: IntElement
ExcludeCharList: StringElement
InvalidAction: IntElement
InvalidAttempts: IntElement
LimitAdjacent: IntElement
LimitRepeating: IntElement
LoginMaxLength: IntElement
LoginMinLength: IntElement
LowerCaseRequired: IntElement
MaxPasswordAge: IntElement
MaxPasswordLength: IntElement
MinPasswordAge: IntElement
MinPasswordLength: IntElement
MlaMaxLength: IntElement
MlaMinLength: IntElement
MlaRequireAlpha: BoolElement
MlaRequireNumeric: BoolElement
NewPwdExpirationHours: IntElement
NumbersRequired: IntElement
OobInvalidAction: IntElement
OobInvalidAttempts: IntElement
PasswordHistoryNumber: IntElement
PasswordPolicyID: IntElement
QuestionMinLength: IntElement
SpecialCharRequired: IntElement
TACDeliveryViaEmail: IntElement
TACDeliveryViaSMS: BoolElement
TACDeliveryViaVoice: IntElement
TACLength: IntElement
TACRequiredLostPwd: IntElement
TACTTLMinutes: IntElement
UISourceID: IntElement
UpperCaseRequired: IntElement
[docs]
@dataclass
class DalPasswordPolicyByUISourceId:
Q2_PasswordPolicyByUISourceId: Union[
Q2_PasswordPolicyByUISourceId, List[Q2_PasswordPolicyByUISourceId]
]
[docs]
@dataclass
class Data:
DalPasswordPolicyByUISourceId: Union[
DalPasswordPolicyByUISourceId, List[DalPasswordPolicyByUISourceId]
]
[docs]
class ResultNode:
def __init__(self):
self.Data = Data()
[docs]
class HqResponse(HqResponse):
def __init__(self, raw_response: Union[str, dict]):
super().__init__(raw_response)
self.result_node: ResultNode = None
[docs]
async def execute(params_obj: ParamsObj, use_json=False, **kwargs) -> HqResponse:
"""
This is the default way to submit the request to HQ.
In theory, both json and soap payloads are equally accepted by HQ, though
several variables may affect that (HQ version, Q2SDK implementation bugs, etc).
This should not affect anything about the way your code deals with the data. In fact,
the only difference to consuming extensions is the logging.
Basically, call this with default parameters unless you find a compelling
reason not to.
:param params_obj: Object containing everything necessary to call this HQ endpoint
:param use_json: If True, will call HQ's .ashx (json) endpoint instead of .asmx (soap)
"""
request = Q2ApiRequest("GetPasswordPolicy", use_json=use_json, **kwargs)
return await request.execute(params_obj, **kwargs)
[docs]
async def get_soap(params_obj: ParamsObj, **kwargs) -> HqResponse:
"""Deprecated. Please use execute instead"""
params_obj.logger.warning(
"GetPasswordPolicy.get_soap is deprecated. Please use GetPasswordPolicy.execute instead."
)
return await execute(params_obj, **kwargs)
[docs]
async def get_json(params_obj: ParamsObj, **kwargs) -> HqResponse:
"""Deprecated. Please use execute instead"""
params_obj.logger.warning(
"GetPasswordPolicy.get_json is deprecated. Please use GetPasswordPolicy.execute instead."
)
return await execute(params_obj, use_json=True, **kwargs)
[docs]
def build_json(params_obj: ParamsObj):
return Q2ApiRequest.build_json(params_obj)
[docs]
def build_soap(params_obj: ParamsObj):
return Q2ApiRequest("GetPasswordPolicy", use_json=False).build_soap(params_obj)