

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 隱私權相關函數
<a name="privacy-related-functions"></a>

AWS Clean Rooms 提供 函數，可協助您符合下列規格的隱私權相關合規。
+ **全球隱私權平台 (GPP)** – 互動式廣告局 (IAB) 的規格，可建立適用於線上隱私權和資料使用的全球標準化架構。如需 GPP 技術規格的詳細資訊，請參閱 [ GitHub 上的全球隱私權平台文件](https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform)。
+ **透明度和同意架構 (TCF)** – GPP 的關鍵元件，於 2020 年推出，提供標準化的技術架構，協助公司遵守隱私權法規，例如歐盟一般資料保護法規 (GDPR)。TCF 可讓客戶授予或暫停對資料收集和處理的同意。如需 TCF 技術規格的詳細資訊，請參閱 [ GitHub 上的 TCF 文件](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/tree/master/TCFv2)。

**Topics**
+ [consent\$1gpp\$1v1\$1decode 函數](consent_gpp_v1_decode.md)
+ [consent\$1tcf\$1v2\$1decode 函數](consent_tcf_v2_decode.md)

# consent\$1gpp\$1v1\$1decode 函數
<a name="consent_gpp_v1_decode"></a>

`consent_gpp_v1_decode` 函數用於解碼全球隱私權平台 (GPP) v1 同意資料。它以編碼的同意字串做為輸入，並傳回解碼的同意資料，其中包括使用者隱私權偏好設定和同意選擇的相關資訊。此函數在處理包含 GPP v1 同意資訊的資料時非常有用，因為它可讓您以結構化格式存取和分析同意資料。

## 語法
<a name="consent_gpp_v1_decode-syntax"></a>

```
consent_gpp_v1_decode(gpp_string)
```

## 引數
<a name="consent_gpp_v1_decode-arguments"></a>

 *gpp\$1string*   
編碼的 GPP v1 同意字串。

## 傳回值
<a name="consent_gpp_v1_decode-returm-type"></a>

傳回的字典包含下列鍵值對：
+ `version`：使用的 GPP 規格版本 （目前為 1)。
+ `cmpId`：編碼同意字串的同意管理平台 (CMP) ID。
+ `cmpVersion`：編碼同意字串的 CMP 版本。
+ `consentScreen`：使用者提供同意的 CMP UI 中的畫面 ID。
+ `consentLanguage`：同意資訊的語言代碼。
+ `vendorListVersion`：使用的廠商清單版本。
+ `publisherCountryCode`：發佈者的國家/地區代碼。
+ `purposeConsent`：整數清單，代表使用者同意的目的。
+ `purposeLegitimateInterest`：已透明地傳達使用者合法利益的目的 IDs 清單。
+ `specialFeatureOptIns`：整數清單，代表使用者已選擇加入的特殊功能。
+ `vendorConsent`：使用者已同意的供應商 IDs清單。
+ `vendorLegitimateInterest`：已透明地傳達使用者合法利益的供應商 IDs 清單。

## 範例
<a name="consent_gpp_v1_decode-example"></a>

下列範例採用單一引數，也就是編碼的同意字串。它會傳回包含解碼同意資料的字典，包括使用者隱私權偏好設定、同意選擇和其他中繼資料的相關資訊。

```
SELECT * FROM consent_gpp_v1_decode('ABCDEFGHIJK');
```

傳回之同意資料的基本結構包括同意字串版本、CMP （同意管理平台） 詳細資訊、使用者對不同用途和供應商的同意和合法利益選擇，以及其他中繼資料的相關資訊。

```
{
    "version": 1,
    "cmpId": 12,
    "cmpVersion": 34,
    "consentScreen": 5,
    "consentLanguage": "en",
    "vendorListVersion": 89,
    "publisherCountryCode": "US",
    "purposeConsent": [1],
    "purposeLegitimateInterests": [1],
    "specialFeatureOptins": [1],
    "vendorConsent": [1],
    "vendorLegitimateInterests": [1]}
}
```

# consent\$1tcf\$1v2\$1decode 函數
<a name="consent_tcf_v2_decode"></a>

`consent_tcf_v2_decode` 函數用於解碼透明度和同意架構 (TCF) v2 同意資料。它以編碼的同意字串做為輸入，並傳回解碼的同意資料，其中包括使用者隱私權偏好設定和同意選擇的相關資訊。此函數在處理包含 TCF v2 同意資訊的資料時非常有用，因為它可讓您以結構化格式存取和分析同意資料。

## 語法
<a name="consent_tcf_v2_decode-syntax"></a>

```
consent_tcf_v2_decode(tcf_string)
```

## 引數
<a name="consent_tcf_v2_decode-arguments"></a>

 *tcf\$1string*   
編碼的 TCF v2 同意字串。

## 傳回值
<a name="consent_tcf_v2_decode-return-type"></a>

`consent_tcf_v2_decode` 函數會傳回字典，其中包含來自透明度和同意架構 (TCF) v2 同意字串的解碼同意資料。

傳回的字典包含下列鍵值對：

**核心區段**
+ `version`：使用的 TCF 規格版本 （目前為 2)。
+ `created`：建立同意字串的日期和時間。
+ `lastUpdated`：上次更新同意字串的日期和時間。
+ `cmpId`：編碼同意字串的同意管理平台 (CMP) ID。
+ `cmpVersion`：編碼同意字串的 CMP 版本。
+ `consentScreen`：使用者提供同意的 CMP UI 中的畫面 ID。
+ `consentLanguage`：同意資訊的語言代碼。
+ `vendorListVersion`：使用的廠商清單版本。
+ `tcfPolicyVersion`：同意字串所依據的 TCF 政策版本。
+ `isServiceSpecific`：布林值，指出同意是針對特定服務，還是適用於所有服務。
+ `useNonStandardStacks`：布林值，指出是否使用非標準堆疊。
+ `specialFeatureOptIns`：整數清單，代表使用者已選擇加入的特殊功能。
+ `purposeConsent`：整數清單，代表使用者同意的目的。
+ `purposesLITransparency`：整數清單，代表使用者已提供合法利益透明度的目的。
+ `purposeOneTreatment`：布林值，指出使用者是否已請求「目的一處理」 （也就是說，所有目的都會受到同等對待）。
+ `publisherCountryCode`：發佈者的國家/地區代碼。
+ `vendorConsent`：使用者已同意的供應商 IDs清單。
+ `vendorLegitimateInterest`：已透明地傳達使用者合法利益的供應商 IDs 清單。
+ `pubRestrictionEntry`：發佈者限制的清單。此欄位包含用途 ID、限制類型，以及該用途限制下的廠商 IDs 清單。

**已公開的供應商客群**
+ `disclosedVendors`：整數清單，代表已向使用者公開的廠商。

**發佈者用途區段**
+ `pubPurposesConsent`：整數清單，代表使用者已同意的發佈者特定目的。
+ `pubPurposesLITransparency`：整數清單，代表使用者已提供合法利益透明度的發佈者特定目的。
+ `customPurposesConsent`：整數清單，代表使用者已同意的自訂目的。
+ `customPurposesLITransparency`：整數清單，代表使用者已提供合法利益透明度的自訂目的。

此詳細同意資料可用於了解和尊重使用者使用個人資料時的隱私權偏好設定。

## 範例
<a name="consent_tcf_v2_decode-examples"></a>

下列範例採用單一引數，也就是編碼的同意字串。它會傳回包含解碼同意資料的字典，包括使用者隱私權偏好設定、同意選擇和其他中繼資料的相關資訊。

```
from aws_clean_rooms.functions import consent_tcf_v2_decode

consent_string = "CO1234567890abcdef"
consent_data = consent_tcf_v2_decode(consent_string)

print(consent_data)
```

傳回之同意資料的基本結構包括同意字串版本、CMP （同意管理平台） 詳細資訊、使用者對不同用途和供應商的同意和合法利益選擇，以及其他中繼資料的相關資訊。

```
    /** core segment **/
    version: 2,
    created: "2023-10-01T12:00:00Z",
    lastUpdated: "2023-10-01T12:00:00Z",
    cmpId: 1234,
    cmpVersion: 5,
    consentScreen: 1,
    consentLanguage: "en",
    vendorListVersion: 2,
    tcfPolicyVersion: 2,
    isServiceSpecific: false,
    useNonStandardStacks: false,
    specialFeatureOptIns: [1, 2, 3],
    purposeConsent: [1, 2, 3],
    purposesLITransparency: [1, 2, 3],
    purposeOneTreatment: true,
    publisherCountryCode: "US",
    vendorConsent: [1, 2, 3],
    vendorLegitimateInterest: [1, 2, 3],
    pubRestrictionEntry: [
        { purpose: 1, restrictionType: 2, restrictionDescription: "Example restriction" },
    ],

    /** disclosed vendor segment **/
    disclosedVendors: [1, 2, 3],

    /** publisher purposes  segment **/
    pubPurposesConsent: [1, 2, 3],
    pubPurposesLITransparency: [1, 2, 3],
    customPurposesConsent: [1, 2, 3],
    customPurposesLITransparency: [1, 2, 3],
};
```