---
schema_version: "1"
id: 78b1b74f99d2ebaf28989bbed0e4f6e6d8ea93cf2e160fa29ffb24c8ad1f8c8b
title: ポリシー違反のレポート
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/pdk/1.4/policies-pdk-configure-features-violations.md
canonical_url: https://docs.mulesoft.com/jp/pdk/1.4/policies-pdk-configure-features-violations
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a9ea9c85c2945bcfb7ea76cfa5fd01da895b42e6142e137e2dc300a7c20d4231
description: MuleSoft Documentation Site
release: "1.4"
latest: false
---
# ポリシー違反のレポート

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">ポリシー違反のレポートの例については、 <a href="https://github.com/mulesoft/pdk-custom-policy-examples/blob/1.4.0/stream-payload/README.md">「Stream Payload Policy (ストリームペイロードポリシーの収集)」</a>​を参照してください。</td></tr></tbody></table>

PDK には、ポリシー違反をレポートする関数があります。レポートされたポリシー違反は、Anypoint Monitoring に表示されます。

要求に対して一度に 1 つのポリシー違反のみがアクティブになります。新しい違反が発生すると、既存の違反が上書きされます。複数のポリシーで 1 つの要求の違反が生成されても、Anypoint Monitoring には 1 つの違反のみが表示されます。

ポリシー違反がレポートされても、要求は拒否されません。要求を拒否するには、[要求実行の停止](https://docs.mulesoft.com/jp/pdk/1.4/policies-pdk-configure-features-stop)を参照してください。

現在のポリシー違反を表示したり、新しいポリシー違反を生成するには、次の PDK 関数を使用します。

```Rust
/// Returns the existing policy violation of the current request. Returns None if no violation exists.
pub fn policy_violation(&self) -> Option<PolicyViolation>;

/// Generates a new policy violation for the current request. If a violation was previously generated, the previous violation is overridden.
pub fn generate_policy_violation(&self);

/// Generates a new policy violation with the client application details for the current request. This overwrites any previous policy violations.
pub fn generate_policy_violation_for_client_app<T: Into<String>, K: Into<String>>(
   &self,
   client_name: T,
   client_id: K,
);
```

現在のポリシー違反に関する情報を取得するには、次の PDK 関数を使用します。

```Rust
    /// The name of the policy that generated the violation
   pub fn get_policy_name(&self) -> &str;

   /// Client name associated with the violation, only available if a previous policy reported the client ID
   pub fn get_client_name(&self) -> Option<&str>;

   /// Client ID associated with the violation, only available if a previous policy reported the client ID
   pub fn get_client_id(&self) -> Option<&str>;
```

## [](#関連情報)関連情報

- [パラメーターの挿入](https://docs.mulesoft.com/jp/pdk/1.4/policies-pdk-configure-features-inject-parameters)