MonetizationLimitsCheck ポリシー

<ph type="x-smartling-placeholder"></ph> 現在、Apigee Edge のドキュメントが表示されています。
Apigee X のドキュメント
詳細

概要

MonetizationLimitsCheck ポリシーを使用すると、API 呼び出しに対して収益化の上限を適用できます。 必要があります。

ポリシーがトリガーされるのは、たとえば次のような場合です。

  • 収益化対象の API にアクセスするアプリ デベロッパーが、 関連する API プロダクト
  • デベロッパーのアカウントの残高が不足しています。
  • デベロッパーのトランザクション量が上限を超えています。

ポリシーを API プロキシに接続する方法については、以下をご覧ください。 API プロキシに収益化の上限を適用します

<MonetizationLimitsCheck> 要素

MonetizationLimitsCheck ポリシーを指定します。

デフォルト値 なし
必須かどうか 必須
複合型
親要素 なし
子要素 <DisplayName>
<FaultResponse>
<IgnoreUnresolvedVariables>
<Variables>

次の表に、<MonetizationLimitsCheck> の子要素の概要を示します。

子要素 必須かどうか 説明
<DisplayName> 省略可 ポリシーのカスタム名。
<FaultResponse> 省略可 次の場合にリクエスト元のクライアントに返されるレスポンス メッセージを指定します。 発生します。
<IgnoreUnresolvedVariables> 省略可 未解決の変数に突き当たった場合に、処理を停止するかどうかを決定します。
<Variables> 省略可 収益化の上限を確認するフロー変数を指定します。

<MonetizationLimitsCheck> 要素の構文は次のとおりです。

構文

<?xml version="1.0" encoding="UTF-8"?>
<MonetizationLimitsCheck async="false" continueOnError="false" enabled="true" name="POLICY_NAME">
    <DisplayName>DISPLAY_NAME</DisplayName>
    <IgnoreUnresolvedVariables>[true|false]</IgnoreUnresolvedVariables>
    <Variables>
        <Product>VARIABLE_NAME</Product>
    </Variables>
    <FaultResponse>
        <Set>
            <Payload contentType="text/xml">
                <error>
                    <messages>
                        <message>MESSAGE_TEXT</message>
                        <message>MESSAGE_TEXT</message>
                    </messages>
                </error>
            </Payload>
            <StatusCode>HTTP_STATUS</StatusCode>
            <ReasonPhrase>REASON_TEXT</ReasonPhrase>
        </Set>
    </FaultResponse>
</MonetizationLimitsCheck>

次の例は、MonetizationLimitsCheck ポリシーの定義を示しています。

<?xml version="1.0" encoding="UTF-8"?>
<MonetizationLimitsCheck async="false" continueOnError="false" enabled="true" name="Monetization-Limits-Check">
    <DisplayName>Monetization Limits Check</DisplayName>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <Variables>
        <Product>myproductvar.name</Product>
    </Variables>
	<FaultResponse>
	        <Set>
	            <Payload contentType="text/xml">
	                <error>
	                    <messages>
	                        <message>Developer has reached usage quota</message>
	                        <message>Is Developer Suspended - {monetizationLimits.isDeveloperSuspended} </message>
	                    </messages>
	                </error>
	            </Payload>
	            <StatusCode>403</StatusCode>
	            <ReasonPhrase>Forbidden</ReasonPhrase>
	        </Set>
	</FaultResponse>
 </MonetizationLimitsCheck>

This element has the following attributes that are common to all policies:

Attribute Default Required? Description
name N/A Required

The internal name of the policy. The value of the name attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the <DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

continueOnError false Optional Set to "false" to return an error when a policy fails. This is expected behavior for most policies. Set to "true" to have flow execution continue even after a policy fails.
enabled true Optional Set to "true" to enforce the policy. Set to "false" to "turn off" the policy. The policy will not be enforced even if it remains attached to a flow.
async   false Deprecated This attribute is deprecated.

子要素のリファレンス

このセクションでは、<MonetizationLimitsCheck> の子要素について説明します。

<DisplayName>

name 属性に加えて、管理 UI プロキシ エディタでポリシーを別の、より自然な響きの名前でラベル付けするために使います。

<DisplayName> 要素はすべてのポリシーに共通です。

デフォルト値 なし
必須 省略可。<DisplayName> を省略した場合、ポリシーの name 属性の値が使用されます。
文字列
親要素 <PolicyElement>
子要素 なし

<DisplayName> 要素の構文は次のとおりです。

構文

<PolicyElement>
  <DisplayName>policy_display_name</DisplayName>
  ...
</PolicyElement>

<PolicyElement>
  <DisplayName>My Validation Policy</DisplayName>
</PolicyElement>

<DisplayName> 要素に属性や子要素はありません。

<IgnoreUnresolvedVariables>

Apigee が未解決の変数を検出したときに、ポリシーの処理を停止するかどうかを決定します。

デフォルト値 True
必須かどうか 省略可
ブール値
親要素 <MonetizationLimitsCheck>
子要素 なし

未解決の変数を無視して処理を続行するには、値を true に設定します。 それ以外の場合は false になります。デフォルト値は true です。

<IgnoreUnresolvedVariables>true に設定することは、<MonetizationLimitsCheck> 要素を設定することとは異なります。 continueOnError から true に変更。continueOnErrortrue に設定した場合、Apigee は 変数エラーだけを抽出できます。

<IgnoreUnresolvedVariables> 要素の構文は次のとおりです。

構文

<IgnoreUnresolvedVariables>[true|false]</IgnoreUnresolvedVariables>

次の例では、<IgnoreUnresolvedVariables>false に設定します。

<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>

<Variables>

フェッチするフロー変数を指定します。 エンティティ名またはリソース名に 追加することもできます

<Variables> 要素内には <Product> 要素のみを指定できます。Apigee は <Product> 要素で指定されたフロー変数から API プロダクト名。もし <Variables> 要素を指定しない場合、Apigee はデフォルトで apiproduct.name コンテキスト変数。API プロダクト名を使用すると、Apigee は 対応する料金プランを確認し、収益化の上限のチェックを行います。

デフォルト値 なし
必須かどうか 省略可
複合型
親要素 <MonetizationLimitsCheck>
子要素 <Product>

<Variables> 要素の構文は次のとおりです。

構文

<Variables>
    <Product>VARIABLE_NAME</Product>
</Variables>

次の例では、myproductvar.name カスタムフロー変数から API プロダクト名を取得しています。 API プロキシフローに存在するだけです。

<Variables>
    <Product>myproductvar.name</Product>
</Variables>

カスタムフロー変数を設定するには、AssignMessageJavaScript などのポリシーを使用します。

<Product>

API プロダクト名を持つ変数を指定します。

デフォルト値 なし
必須かどうか 省略可
文字列
親要素 <Variables>
子要素 なし

<Product> 要素の構文は次のとおりです。

構文

<Product>VARIABLE_NAME</Product>

次の例では、myproductvar.name カスタムフロー変数から API プロダクト名を取得しています。 API プロキシフローに存在するだけです。

<Product>myproductvar.name</Product>

カスタムフロー変数を設定するには、AssignMessageJavaScript などのポリシーを使用します。

<FaultResponse>

エラーが発生したときにリクエスト元のクライアントに返されるレスポンス メッセージを定義します。 レスポンスはカスタマイズ可能 メッセージを作成できます。詳細については、 要素とそのすべての子要素については、FaultResponse をご覧ください。

フロー変数

<MonetizationLimitsCheck> 要素の ContinueOnError 属性を true に設定すると、エラーは発生しません。この例では、 フロー変数、mint.limitsViolatedmint.isDeveloperSuspendedmint.limitsPolicyError は自動的に設定されます。これらの変数を使用して、 必要に応じてさらに例外処理を実行します。