إدارة قوائم التحكم في الوصول لسجل البيانات

في هذه المقالة، ستتعلم كيفية إضافة قوائم التحكم بالوصول أو إزالتها من سجل البيانات في Azure Data Manager لمثيل الطاقة.

إنشاء مجموعة بيانات ك ACL

قم بتشغيل الأمر curl التالي في Azure Cloud Shell لإنشاء مجموعة بيانات جديدة، على سبيل المثال، data.sampledb.viewer، في قسم البيانات المحدد لمثيل Azure Data Manager for Energy.

تنسيق الطلب

    curl --location --request POST "https://<adme-url>/api/entitlements/v2/groups/" \
    --header 'data-partition-id: <data-partition>' \
    --header 'Authorization: Bearer <access_token>'
    --data-raw '{
       "description": "<data-group-description>",
       "name": "data.sampledb.viewer"
    }

إنشاء سجل باستخدام قوائم التحكم بالوصول

تنسيق الطلب

curl --location --request PUT 'https://<adme-url>/api/storage/v2/records/' \
--header 'data-partition-id: opendes' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>’ \
--header 'Content-Type: application/json' \	
--data-raw '[
  {
    "acl": {
      "owners": [
        "data.default.owners@opendes.contoso.com",
        "data.wellbore1.owner@opendes.contoso.com"
      ],
      "viewers": [
        "data.default.viewers@opendes.contoso.com"
      ]
    },
    "data": {
        "FacilityID": "Example External Facility Identifier",
        "Source": "Create Record test"
      },
    "id": "opendes:master-data--Well:999635346360",
    "kind": "osdu:wks:master-data--Well:1.0.0",
    "legal": {
      "legaltags": [
        "opendes-Test-Legal-Tag-2311232"
      ],
      "otherRelevantDataCountries": [
        "US"
      ],
      "status": "compliant"
    },
    "meta": [
      {}
    ],
    "version": 0
  }
]

نموذج الاستجابة

{
    "recordCount": 1,
    "recordIds": [
        "opendes:master-data--Well:999736019023"
    ],
    "skippedRecordIds": [],
    "recordIdVersions": [
        "opendes:master-data--Well:999736019023:1702017200855277"
    ]
}

احتفظ ب معرف السجل من الاستجابة في متناول اليد للمراجع المستقبلية.

الحصول على سجل تم إنشاؤه باستخدام قوائم التحكم بالوصول

تنسيق الطلب

curl --location 'https://<adme-url>/api/storage/v2/records/opendes:master-data--Well:999736019023' \
--header 'data-partition-id: opendes' \
--header 'Authorization: Bearer <token>’

نموذج الاستجابة

{
    "data": {
        "FacilityID": "Example External Facility Identifier",
        "Source": "Create Record test"
    },
    "meta": [
        {}
    ],
    "id": "opendes:master-data--Well:999736019023",
    "version": 1702017200855277,
    "kind": "osdu:wks:master-data--Well:1.0.0",
    "acl": {
        "viewers": [
            "data.default.viewers@opendes.contoso.com"
        ],
        "owners": [
            "data.default.owners@opendes.contoso.com",
            "data.wellbore1.owner@opendes.contoso.com"
        ]
    },
    "legal": {
        "legaltags": [
            "opendes-Test-Legal-Tag-2311232"
        ],
        "otherRelevantDataCountries": [
            "US"
        ],
        "status": "compliant"
    },
    "createUser": "preshipping@azureglobal1.onmicrosoft.com",
    "createTime": "2023-12-08T06:33:21.338Z"
}

حذف قوائم التحكم بالوصول من سجل البيانات

تقوم العملية الأولى /acl/owners/0 بإزالة ACL من الموضع 0 في صفيف ACL. عند حذف الإدخال الأول مع هذه العملية، يحذفه النظام. ثم يصبح الإدخال الثاني السابق هو الإدخال الأول. تحاول العملية الثانية /acl/owners/0 إزالة الإدخال الثاني.

تنسيق الطلب

curl --location --request PATCH 'https://<adme-url>/api/storage/v2/records/' \
--header 'data-partition-id: opendes' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <token>’\
--header 'Content-Type: application/json-patch+json' \
--data '
{
    "query": {
        "ids": ["opendes:master-data--Well:999736019023"]
    },
    "ops": [
        { 
          "op": "remove", 
          "path": "/acl/owners/0"
        }
      ]
}

نموذج الاستجابة

{
      "recordCount": 1,
      "recordIds": [
          "opendes:master-data--Well:999736019023:1702017200855277"
      ],
      "notFoundRecordIds": [],
      "failedRecordIds": [],
      "errors": []
}

إذا قمت بحذف آخر مالك ACL من سجل البيانات، فستحصل على الخطأ.

نموذج الاستجابة

{
    "recordCount": 0,
    "recordIds": [],
    "notFoundRecordIds": [],
    "failedRecordIds": [
        "opendes:master-data--Well: 999736019023"
    ],
    "errors": [
        "Patch operation for record: opendes:master-data--Well:999512152273 aborted. Potentially empty value of legaltags or acl/owners or acl/viewers"
    ]
}

الخطوات التالية

بعد إضافة قوائم التحكم بالوصول إلى سجلات البيانات، يمكنك:

يمكنك أيضا استيعاب البيانات في Azure Data Manager لمثيل الطاقة: