a f.@sddlmZddlmZddlmZddlmZmZddlm Z ddl m Z m Z ddl mZddlmZmZmZdd lmZdd lmZd d lmZed ZGdddeZdS))absolute_import)requests)six)retrycircuit_breaker) BaseClient)get_config_value_or_defaultvalidate_config)Signer)Sentinel#get_signer_from_authentication_typeAUTHENTICATION_TYPE_FIELD_NAME)InvalidAlloyConfig)OCI_SDK_ENABLED_SERVICES_SET)usage_type_mappingZMissingc@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS) RewardsClienta Use the Usage Proxy API to list Oracle Support Rewards, view related detailed usage information, and manage users who redeem rewards. For more information, see [Oracle Support Rewards Overview](/iaas/Content/Billing/Concepts/supportrewardsoverview.htm). c Ks&tdstdt||ddd|vr6|d}nDt|vrHt|}n2t|d|d|d|dt|d |d d }d |d ddi|dd|dt j |dd}d|vr|d|d<|ddurt j |d<d|vr|d|d<t d||t fi||_|d|_|d|_dS)a Creates a new service client :param dict config: Configuration keys and values as per `SDK and Tool Configuration `__. The :py:meth:`~oci.config.from_file` method can be used to load configuration from a file. Alternatively, a ``dict`` can be passed. You can validate_config the dict using :py:meth:`~oci.config.validate_config` :param str service_endpoint: (optional) The endpoint of the service to call using this client. For example ``https://iaas.us-ashburn-1.oraclecloud.com``. If this keyword argument is not provided then it will be derived using the region in the config parameter. You should only provide this keyword argument if you have an explicit need to specify a service endpoint. :param timeout: (optional) The connection and read timeouts for the client. The default values are connection timeout 10 seconds and read timeout 60 seconds. This keyword argument can be provided as a single float, in which case the value provided is used for both the read and connection timeouts, or as a tuple of two floats. If a tuple is provided then the first value is used as the connection timeout and the second value as the read timeout. :type timeout: float or tuple(float, float) :param signer: (optional) The signer to use when signing requests made by the service client. The default is to use a :py:class:`~oci.signer.Signer` based on the values provided in the config parameter. One use case for this parameter is for `Instance Principals authentication `__ by passing an instance of :py:class:`~oci.auth.signers.InstancePrincipalsSecurityTokenSigner` as the value for this keyword argument :type signer: :py:class:`~oci.signer.AbstractBaseSigner` :param obj retry_strategy: (optional) A retry strategy to apply to all calls made by this service client (i.e. at the client level). There is no retry strategy applied by default. Retry strategies can also be applied at the operation level by passing a ``retry_strategy`` keyword argument as part of calling the operation. Any value provided at the operation level will override whatever is specified at the client level. This should be one of the strategies available in the :py:mod:`~oci.retry` module. A convenience :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` is also available. The specifics of the default retry strategy are described `here `__. :param obj circuit_breaker_strategy: (optional) A circuit breaker strategy to apply to all calls made by this service client (i.e. at the client level). This client uses :py:data:`~oci.circuit_breaker.DEFAULT_CIRCUIT_BREAKER_STRATEGY` as default if no circuit breaker strategy is provided. The specifics of circuit breaker strategy are described `here `__. :param function circuit_breaker_callback: (optional) Callback function to receive any exceptions triggerred by the circuit breaker. :param bool client_level_realm_specific_endpoint_template_enabled: (optional) A boolean flag to indicate whether or not this client should be created with realm specific endpoint template enabled or disable. By default, this will be set as None. :param allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this client should allow control characters in the response object. By default, the client will not allow control characters to be in the response object. usageaThe Alloy configuration has disabled this service, this behavior is controlled by OCI_SDK_ENABLED_SERVICES_SET variable. Please check if your local alloy-config file configured the service you're targeting or contact the cloud provider on the availability of this servicesigner)rtenancyuser fingerprintZkey_file pass_phraseZ key_content)rrrZprivate_key_file_locationrZprivate_key_contentTservice_endpointz /20190111z1https://identity.{region}.oci.{secondLevelDomain}skip_deserializationFcircuit_breaker_strategy5client_level_realm_specific_endpoint_template_enabled)Zregional_clientr base_pathZservice_endpoint_templateZ#service_endpoint_template_per_realmrrrtimeoutNallow_control_charsZrewardsretry_strategycircuit_breaker_callback)rZis_service_enabledrr getr r r rrZGLOBAL_CIRCUIT_BREAKER_STRATEGYZ DEFAULT_CIRCUIT_BREAKER_STRATEGYrr base_clientr r!)selfZconfigkwargsrZbase_client_init_kwargsr&`__. To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. :param bool allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage.models.RedeemableUserCollection` :rtype: :class:`~oci.response.Response` :example: Click `here `__ to see an example of how to use create_redeemable_user API. subscriptionId tenancyId//subscriptions/{subscriptionId}/redeemableUsersZPOSTcreate_redeemable_userz^https://docs.oracle.com/iaas/api/#/en/usage-proxy/20190111/RedeemableUser/CreateRedeemableUser)rr user_idopc_request_idif_matchopc_retry_tokencsg|]}|vr|qSr&r&.0Z_keyZexpected_kwargsr&r' z8RewardsClient.create_redeemable_user..z+create_redeemable_user got unknown kwargs: cSsi|]\}}|tur||qSr&missingr2kvr&r&r' r5z8RewardsClient.create_redeemable_user..Nr Parameter + cannot be None, whitespace or empty stringr-)r*ZuserIdcSs&i|]\}}|tur|dur||qSNr6r8r&r&r'r;r5application/jsonr.r/r0)accept content-typeopc-request-idif-matchzopc-retry-tokencSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r Zoperation_retry_strategyZclient_retry_strategyRedeemableUserCollectionr) resource_pathmethod path_params query_params header_paramsbody response_typeroperation_nameapi_reference_linkrequired_arguments)riterkeys ValueError iteritems isinstance string_typeslenstripr"r7r#get_preferred_retry_strategyr rNoneRetryStrategyZadd_opc_retry_token_if_neededadd_opc_client_retries_headeradd_circuit_breaker_callbackr!make_retrying_callcall_api)r$Zcreate_redeemable_user_details tenancy_idsubscription_idr%rOrFrGrMrN extra_kwargsrHr9r:rIrJr r&r3r'r,ws5$       z$RewardsClient.create_redeemable_userc sgd}d}d}d}d} gdfddt|D} | rJtd | d |i} d d t| D} t| D]<\} } | d ust| tjrpt| dkrptd| dqp||d}dd t|D}dd|dt |dt d}dd t|D}|j j |d|j d}|rjt|t jsB|j |||j|j|j j||| |||d|| |d S|j j||| |||d|| |d Sd S)a/ Deletes the list of redeemable user email ID for a subscription ID. :param str email_id: (required) The email ID that needs to be deleted. :param str tenancy_id: (required) The OCID of the tenancy. :param str subscription_id: (required) The subscription ID for which rewards information is requested for. :param str opc_request_id: (optional) Unique, Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. :param str if_match: (optional) For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted, only if the etag you provide matches the resource's current etag value. :param obj retry_strategy: (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. The specifics of the default retry strategy are described `here `__. To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. :param bool allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings :return: A :class:`~oci.response.Response` object with data of type None :rtype: :class:`~oci.response.Response` :example: Click `here `__ to see an example of how to use delete_redeemable_user API. )r)emailIdr*r+ZDELETEdelete_redeemable_userz^https://docs.oracle.com/iaas/api/#/en/usage-proxy/20190111/RedeemableUser/DeleteRedeemableUser)rr r.r/csg|]}|vr|qSr&r&r1r3r&r'r46r5z8RewardsClient.delete_redeemable_user..z+delete_redeemable_user got unknown kwargs: r)cSsi|]\}}|tur||qSr&r6r8r&r&r'r;?r5z8RewardsClient.delete_redeemable_user..Nrr<r=)r`r*cSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;Ir5r?r.r/)r@rArBrCcSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;Qr5r rDr) rFrGrHrIrJrrMrNrOrrPrQrRrSrTrUrVr"r7r#rWr rrXrYrZr!r[r\)r$Zemail_idr]r^r%rOrFrGrMrNr_rHr9r:rIrJr r&r3r'rast+$     z$RewardsClient.delete_redeemable_userc sDgd}d}d}d}d} gdfddt|D} | rJtd | d |i} d d t| D} t| D]<\} } | d ust| tjrpt| dkrptd| dqpd|vrddg}|d|vrtd|d|vrddg}|d|vrtd|d|vr4gd}|d|vr4td||||dt |dt |dt |dt |dt d}dd t|D}d d |d!t d"}d#d t|D}|j j |d$|j d%}|rt|t js|j |||j|j|j j||| ||d&|d'|| |d( S|j j||| ||d&|d'|| |d( Sd S))a Provides product information that is specific to a reward usage period and its usage details. :param str tenancy_id: (required) The OCID of the tenancy. :param str subscription_id: (required) The subscription ID for which rewards information is requested for. :param str usage_period_key: (required) The SPM Identifier for the usage period. :param str opc_request_id: (optional) Unique, Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. :param str page: (optional) The value of the 'opc-next-page' response header from the previous call. :param int limit: (optional) The maximum number of items to return in the paginated response. :param str sort_order: (optional) The sort order to use, which can be ascending (ASC) or descending (DESC). Allowed values are: "ASC", "DESC" :param str sort_by: (optional) The field to sort by. Supports one sort order. Allowed values are: "TIMECREATED", "TIMESTART" :param str producttype: (optional) The field to specify the type of product. Allowed values are: "ALL", "ELIGIBLE", "INELIGIBLE" :param obj retry_strategy: (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. The specifics of the default retry strategy are described `here `__. To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. :param bool allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage.models.ProductCollection` :rtype: :class:`~oci.response.Response` :example: Click `here `__ to see an example of how to use list_products API. )r)r*usagePeriodKeyz(/subscriptions/{subscriptionId}/productsGET list_productszVhttps://docs.oracle.com/iaas/api/#/en/usage-proxy/20190111/ProductSummary/ListProducts)rr r.pagelimit sort_ordersort_by producttypecsg|]}|vr|qSr&r&r1r3r&r'r4r5z/RewardsClient.list_products..z"list_products got unknown kwargs: r)cSsi|]\}}|tur||qSr&r6r8r&r&r'r;r5z/RewardsClient.list_products..Nrr<r=rhASCDESC/Invalid value for `sort_order`, must be one of ri TIMECREATED TIMESTART,Invalid value for `sort_by`, must be one of rj)ZALLZELIGIBLEZ INELIGIBLEz0Invalid value for `producttype`, must be one of rfrg)r*rcrfrg sortOrdersortByrjcSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r?r.r@rArBcSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r rDZProductCollectionr rFrGrHrIrJrLrrMrNrOrb)r$r]r^Zusage_period_keyr%rOrFrGrMrNr_rHr9r:sort_order_allowed_valuessort_by_allowed_valuesZproducttype_allowed_valuesrIrJr r&r3r'ress9 $             zRewardsClient.list_productsc s ddg}d}d}d}d}gdfdd t|D} | rJtd | d|i} d d t| D} t| D]<\} } | d ust| tjrpt| dkrptd| dqpd|vrddg} |d| vrtd| d|vrddg}|d|vrtd|||dt |dt |dt |dt d}dd t|D}dd|dt d}d d t|D}|j j |d!|j d"}|rt|t js|j |||j|j|j j||| ||d#|d$|||d% S|j j||| ||d#|d$|||d% Sd S)&a Provides the list of user summary that can redeem rewards for the given subscription ID. :param str tenancy_id: (required) The OCID of the tenancy. :param str subscription_id: (required) The subscription ID for which rewards information is requested for. :param str opc_request_id: (optional) Unique, Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. :param str page: (optional) The value of the 'opc-next-page' response header from the previous call. :param int limit: (optional) The maximum number of items to return in the paginated response. :param str sort_order: (optional) The sort order to use, which can be ascending (ASC) or descending (DESC). Allowed values are: "ASC", "DESC" :param str sort_by: (optional) The field to sort by. Supports one sort order. Allowed values are: "TIMECREATED", "TIMESTART" :param obj retry_strategy: (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. The specifics of the default retry strategy are described `here `__. To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. :param bool allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage.models.RedeemableUserCollection` :rtype: :class:`~oci.response.Response` :example: Click `here `__ to see an example of how to use list_redeemable_users API. r)r*r+rdlist_redeemable_userszdhttps://docs.oracle.com/iaas/api/#/en/usage-proxy/20190111/RedeemableUserSummary/ListRedeemableUsers)rr r.rfrgrhricsg|]}|vr|qSr&r&r1r3r&r'r4Vr5z7RewardsClient.list_redeemable_users..z*list_redeemable_users got unknown kwargs: cSsi|]\}}|tur||qSr&r6r8r&r&r'r;_r5z7RewardsClient.list_redeemable_users..Nrr<r=rhrkrlrmrirnrorprfrg)r*rfrgrqrrcSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;zr5r?r.rscSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r rDrErrtrbr$r]r^r%rOrFrGrMrNr_rHr9r:rurvrIrJr r&r3r'rws1 $          z#RewardsClient.list_redeemable_usersc sddg}d}d}d}d}gdfdd t|D} | rJtd | d|i} d d t| D} t| D]<\} } | d ust| tjrpt| dkrptd| dqpd|vrddg} |d| vrtd| d|vrdg}|d|vrtd|||dt |dt |dt |dt |dt |dt d}dd t|D}dd|dt d }d!d t|D}|j j |d"|j d#}|rt|t js|j |||j|j|j j||| ||d$|d%|||d& S|j j||| ||d$|d%|||d& Sd S)'a Returns the list of redemption for the subscription ID. :param str tenancy_id: (required) The OCID of the tenancy. :param str subscription_id: (required) The subscription ID for which rewards information is requested for. :param datetime time_redeemed_greater_than_or_equal_to: (optional) The starting redeemed date filter for the redemption history. :param datetime time_redeemed_less_than: (optional) The ending redeemed date filter for the redemption history. :param str opc_request_id: (optional) Unique, Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. :param str page: (optional) The value of the 'opc-next-page' response header from the previous call. :param int limit: (optional) The maximum number of items to return in the paginated response. :param str sort_order: (optional) The sort order to use, which can be ascending (ASC) or descending (DESC). Allowed values are: "ASC", "DESC" :param str sort_by: (optional) The field to be used only for list redemptions API. Supports one sort order. Allowed values are: "TIMEREDEEMED" :param obj retry_strategy: (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. The specifics of the default retry strategy are described `here `__. To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. :param bool allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage.models.RedemptionCollection` :rtype: :class:`~oci.response.Response` :example: Click `here `__ to see an example of how to use list_redemptions API. r)r*z+/subscriptions/{subscriptionId}/redemptionsrdlist_redemptionsz\https://docs.oracle.com/iaas/api/#/en/usage-proxy/20190111/RedemptionSummary/ListRedemptions) rr &time_redeemed_greater_than_or_equal_totime_redeemed_less_thanr.rfrgrhricsg|]}|vr|qSr&r&r1r3r&r'r4r5z2RewardsClient.list_redemptions..z%list_redemptions got unknown kwargs: cSsi|]\}}|tur||qSr&r6r8r&r&r'r;r5z2RewardsClient.list_redemptions..Nrr<r=rhrkrlrmriZ TIMEREDEEMEDrprzr{rfrg)r*Z timeRedeemedGreaterThanOrEqualToZtimeRedeemedLessThanrfrgrqrrcSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r?r.rscSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r rDZRedemptionCollectionrrtrbrxr&r3r'rys7 $             zRewardsClient.list_redemptionsc sddg}d}d}d}d}gdfdd t|D} | rJtd | d|i} d d t| D} t| D]<\} } | d ust| tjrpt| dkrptd| dqpd|i} dd t| D} dd|dt d}dd t|D}|j j |d|j d}|r`t|t js6|j |||j|j|j j||| | |d|d|||d S|j j||| | |d|d|||d Sd S)aC Returns the list of rewards for a subscription ID. :param str tenancy_id: (required) The OCID of the tenancy. :param str subscription_id: (required) The subscription ID for which rewards information is requested for. :param str opc_request_id: (optional) Unique, Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID. :param obj retry_strategy: (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level. This should be one of the strategies available in the :py:mod:`~oci.retry` module. This operation will not retry by default, users can also use the convenient :py:data:`~oci.retry.DEFAULT_RETRY_STRATEGY` provided by the SDK to enable retries for it. The specifics of the default retry strategy are described `here `__. To have this operation explicitly not perform any retries, pass an instance of :py:class:`~oci.retry.NoneRetryStrategy`. :param bool allow_control_chars: (optional) allow_control_chars is a boolean to indicate whether or not this request should allow control characters in the response object. By default, the response will not allow control characters in strings :return: A :class:`~oci.response.Response` object with data of type :class:`~oci.usage.models.RewardCollection` :rtype: :class:`~oci.response.Response` :example: Click `here `__ to see an example of how to use list_rewards API. r)r*z'/subscriptions/{subscriptionId}/rewardsrd list_rewardsz[https://docs.oracle.com/iaas/api/#/en/usage-proxy/20190111/MonthlyRewardSummary/ListRewards)rr r.csg|]}|vr|qSr&r&r1r3r&r'r4lr5z.RewardsClient.list_rewards..z!list_rewards got unknown kwargs: cSsi|]\}}|tur||qSr&r6r8r&r&r'r;ur5z.RewardsClient.list_rewards..Nrr<r=cSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;~r5r?r.rscSs&i|]\}}|tur|dur||qSr>r6r8r&r&r'r;r5r rDZRewardCollectionrrtrb)r$r]r^r%rOrFrGrMrNr_rHr9r:rIrJr r&r3r'r|?st!$    zRewardsClient.list_rewardsN) __name__ __module__ __qualname____doc__r(r,rarerwryr|r&r&r&r'rs[u#rN)Z __future__rZ oci._vendorrrZocirrZoci.base_clientrZ oci.configrr Z oci.signerr Zoci.utilr r r Zoci.exceptionsrZ oci.alloyrZmodelsrr7objectrr&r&r&r's