a MfA4@sddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl Z zddl mZWneyddlmZYn0ddlmZddlZeeZeeZdZdZdZd Zd Zd Zd eZd eZzddlmZWneyddl ZYn0e!Z"ddZ#ddZ$ddZ%ddZ&Gddde!Z'e'dddZ(e'dddZ)ddZ*ddZ+ee*ee+iZ,d d!Z-d"d#Z.efd$d%Z/d&d'Z0d(d)Z1d*d+Z2d,d-Z3d.d/Z4d0d1Z5d2d3Z6d4d5Z7dS)6)absolute_importN)six)urlparse)SEEK_SETinstance_principal(delegation_token_with_instance_principalresource_principaldelegation_token_fileauthentication_typeidcCst|tjr|S|turdSt|tjtjfr`|js@tj |}t|tjrX|j ddS| St|tj rt| St|t j rddt|DSt|t jrdd|DSt|ds|Si}t|jD]$}t||t}|turt|||<q|S) zHelper to flatten models into dicts for rendering. The following conversions are applied: * datetime.date, datetime.datetime, datetime.time are converted into ISO8601 UTC strings NT)sepcSsi|]\}}|t|qSto_dict).0kvrrl/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/oci/util.py Izto_dict..cSsg|] }t|qSrr)rrrrr Krzto_dict.. swagger_types) isinstancer string_types NONE_SENTINELdatetimetimetzinfopytzutclocalize isoformatdateabcMapping iteritemsIterablehasattriterkeysrgetattr missing_attrr)objas_dictkeyvaluerrrr0s0         rcCst|}tj|dddS)z9Returns a string of the model flattened as a dict, sortedT)indent sort_keys)rjsondumps)modelr.rrrformatted_flat_dictYs r7cCs|dup|tup||vSN)r) value_to_testallowed_valuesrrr#value_allowed_none_or_none_sentinelcsr;cCsVtjtj|}t|d}|}Wdn1s<0Yt|dS)a Takes a file path and returns a Base64-encoded string which can be provided as the value of the ``user_data`` key in the ``metadata`` dictionary when launching an instance(see :py:class:`~oci.core.models.LaunchInstanceDetails` for more information). :param str file_path: The path to the file whose contents will be Base64-encoded :return: The Base64-encoded string :rtype: str rbNzutf-8) ospath expandvars expanduseropenreadbase64 b64encodedecode) file_path full_pathf file_contentsrrr)file_content_as_launch_instance_user_datags  &rJcsDeZdZdZiZd fdd Zd ddZddZd d ZeZ Z S) SentinelaNamed singletons for clear docstrings. Also used to differentiate an explicit param of None from a lack of argument. .. code-block:: pycon >>> missing = Sentinel("Missing", False) >>> also_missing = Sentinel("Missing", False) >>> assert missing is also_missing >>> repr(missing) >>> assert bool(missing) is False TcsNtj|d}|dur2tt||}tj|<n|j|urJtd||S)Nz;Tried to get existing Sentinel {!r} with wrong truthy value)rK_symbolsgetsuper__new__truthy ValueErrorformat)clsnamerPsentinel __class__rrrOs  zSentinel.__new__cCs||_||_dSr8rTrP)selfrTrPrrr__init__szSentinel.__init__cCs d|jS)Nz<{}>)rRrTrYrrr__repr__szSentinel.__repr__cCs|jSr8)rPr[rrr__bool__szSentinel.__bool__)T)T) __name__ __module__ __qualname____doc__rLrOrZr\r] __nonzero__ __classcell__rrrVrrK{s  rKNoneFrXWaitResourceNotFoundcCsddlm}i}|t}|dur4tjdttj |}tj |s^tjd|t |dd}| }Wdn1s0Y|durtjd||d<|fi|S) Nr)'InstancePrincipalsDelegationTokenSignerzERROR: {} was not provided.z,ERROR: delegation token file not found at {}r)modez)ERROR: delegation_token was not provided.delegation_token)oci.auth.signersrfrM DELEGATION_TOKEN_FILE_FIELD_NAMEoci exceptions InvalidConfigrRr=r>r@isfilerArBstrip)configrf signer_kwargsdelegation_token_file_path#expanded_delegation_token_file_pathrHrirrr4_get_signer_from_delegation_token_instance_principals    * rucCsddlm}|S)Nr)get_resource_principal_signer)rjrv)rqrvrrr#_get_signer_from_resource_principals rwcCst|}t|}||Sr8)#get_authentication_type_from_config AUTH_TYPE_TO_SIGNER_FUNCTION_MAPrM)rq auth_typesigner_functionrrr#get_signer_from_authentication_types r|cCs`|t}|dur tdt|tkrJt|vr4tStj dttntj d|dS)Nz{} not providedzAThe authentication type {} requires config values for the keys {}z+The authentication type {} is not supported) rMAUTHENTICATION_TYPE_FIELD_NAMErQrR1INSTANCE_PRINCIPAL_AUTHENTICATION_TYPE_VALUE_NAMErksj      ) %