Saya perlu membuat pengguna baru di Azure devops menggunakan perpustakaan klien python untuk Azure DevOps REST API.
Saya menulis kode berikut:
from azure.devops.connection import Connection
from azure.devops.v5_0.graph.models import GraphUserCreationContext
from msrest.authentication import BasicAuthentication
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)
graph_client = connection.clients_v5_0.get_graph_client()
addAADUserContext = GraphUserCreationContext("[email protected]")
print(addAADUserContext)
resp = graph_client.create_user(addAADUserContext)
print(resp)
Saya mendapatkan hasilnya:
{'additional_properties': {}, 'storage_key': '[email protected]'}
Dan terjadi kesalahan saat memanggil metode create_user:
azure.devops.exceptions.AzureDevOpsServiceError: VS860015: Must have exactly one of originId or principalName set.
Sebenarnya apa yang harus saya berikan GraphUserPrincipalNameCreationContext ke fungsi create_user.
Saya menemukan sampel .NET yang melakukan ini dalam fungsi bernama AddRemoveAADUserByUPN() : https://github.com/microsoft/azure-devops-dotnet-samples/blob/master/ClientLibrary/Samples/Graph/UsersSample.cs
GraphUserPrincipalNameCreationContext adalah antarmuka dalam contoh ini. Tapi python tidak mendukung antarmuka.
Jadi bagaimana cara mengimplementasikan ini dengan python?