Imagine que é um programador numa empresa de Software de Gestão de Aprendizagem denominada Bellows College que cria cursos de formação e materiais para empresas. Utiliza a experiência de colaboração dos grupos do Microsoft 365 para fornecer conteúdos do curso e gravar exercícios entre os participantes para cursos online e cursos orientados por instrutores. Quer tornar os grupos do Microsoft 365 utilizados para cursos de formação facilmente identificáveis como cursos de formação, o que permite que outros programadores descubram os seus grupos e criem experiências avançadas sobre os seus cursos de aprendizagem.
Para este cenário, este artigo mostra-lhe como:
Descubra as definições de extensão de esquema disponíveis que pode utilizar.
Registrar uma definição de extensão de esquema direcionada a grupos de cursos de treinamento.
Crie um novo grupo com dados personalizados com base na definição da extensão de esquema que registou.
Adicionar, atualizar ou remover dados personalizados em um grupo existente com base em uma definição de extensão de esquema.
Leia um grupo e os dados da extensão.
Elimine a definição da extensão de esquema e os dados da extensão.
Observação
Além dos grupos, as extensões de esquema também são suportadas e podem ser geridas para outros tipos de recursos.
Pré-requisitos
Para reproduzir os passos neste artigo, precisa dos seguintes privilégios:
Inicie sessão num cliente de API, como o Graph Explorer.
Conceda à aplicação as permissões Group.ReadWrite.All e Application.ReadWrite.All delegated para o utilizador com sessão iniciada.
Seja o proprietário de uma aplicação à qual atribui a propriedade da definição da extensão de esquema neste tutorial. Neste tutorial, a aplicação tem o nome extensions-application e tem appIdd1e6f196-fca3-48ad-8cd3-1a98e3bd46d2.
Etapa 1. Ver extensões de esquema disponíveis
Em primeiro lugar, como programador, poderá querer que a aplicação reutilize quaisquer definições de extensão de esquema existentes, se estiverem adequadas para fins. No exemplo seguinte, vai consultar extensões de esquema com o nome (pelo ID). bellowscollege_courses Suponha que a resposta mostra que não existem extensões de esquema com o nome bellowscollege_courses no seu inquilino.
GET https://graph.microsoft.com/v1.0/schemaExtensions?$filter=id eq 'bellowscollege_courses'
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.SchemaExtensions.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "id eq 'bellowscollege_courses'";
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphschemaextensions "github.com/microsoftgraph/msgraph-sdk-go/schemaextensions"
//other-imports
)
requestFilter := "id eq 'bellowscollege_courses'"
requestParameters := &graphschemaextensions.SchemaExtensionsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphschemaextensions.SchemaExtensionsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schemaExtensions, err := graphClient.SchemaExtensions().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SchemaExtensionCollectionResponse result = graphClient.schemaExtensions().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "id eq 'bellowscollege_courses'";
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.schema_extensions.schema_extensions_request_builder import SchemaExtensionsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = SchemaExtensionsRequestBuilder.SchemaExtensionsRequestBuilderGetQueryParameters(
filter = "id eq 'bellowscollege_courses'",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.schema_extensions.get(request_configuration = request_configuration)
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions",
"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET schemaExtensions?$select=description,owner",
"value": []
}
Também pode consultar pelo ID como um parâmetro de caminho da seguinte forma: GET https://graph.microsoft.com/v1.0/schemaExtensions/bellowscollege_courses. Se não existirem extensões de esquema que correspondam ao ID, a resposta será 404 Not Found.
Etapa 2. Registar uma definição de extensão de esquema
Quer criar e registar uma nova definição de extensão para cursos de formação no recurso de grupo . Especifique as seguintes propriedades:
id: forneça uma cadeia para esta propriedade, seguindo uma de duas formas:
Opção 1: Concatenar um nome de domínio personalizado verificado para o seu inquilino com um nome para a extensão de esquema. Por exemplo, se o domínio for bellowscollege.come o nome da extensão de esquema for courses, pode utilizar o IDbellowscollege_courses.
Opção 2: uma forma alternativa é fornecer apenas um nome de esquema, como courses, e permitir que o Microsoft Graph gere automaticamente o ID ao adicionar o nome fornecido com uma cadeia alfanumérica aleatória.
Este ID torna-se o nome da propriedade da extensão de esquema num grupo.
description
targetTypes: especifique os tipos de recursos aos quais a extensão de esquema pode ser aplicada. Neste exemplo, o tipo de recurso é Group. Pode adicionar mais tipos de recursos ao atualizar a definição da extensão de esquema mais tarde.
propriedades: especifique as propriedades personalizadas que compõem o esquema. Neste exemplo, especifique as courseIdcourseNamecourseType propriedades personalizadas e e os respetivos tipos. Só são permitidas alterações aditivas depois de criar a definição da extensão de esquema.
proprietário: especifique a aplicação que detém a definição da extensão de esquema. Se estiver a executar este exemplo a partir de uma aplicação que não lhe foi atribuída como proprietário, especifique o appId da aplicação que lhe foi atribuída na propriedade de proprietário .
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SchemaExtension
{
Id = "bellowscollege_courses",
Description = "Bellows College training courses extensions",
TargetTypes = new List<string>
{
"Group",
},
Owner = "d1e6f196-fca3-48ad-8cd3-1a98e3bd46d2",
Properties = new List<ExtensionSchemaProperty>
{
new ExtensionSchemaProperty
{
Name = "courseId",
Type = "Integer",
},
new ExtensionSchemaProperty
{
Name = "courseName",
Type = "String",
},
new ExtensionSchemaProperty
{
Name = "courseType",
Type = "String",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.SchemaExtensions.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSchemaExtension()
id := "bellowscollege_courses"
requestBody.SetId(&id)
description := "Bellows College training courses extensions"
requestBody.SetDescription(&description)
targetTypes := []string {
"Group",
}
requestBody.SetTargetTypes(targetTypes)
owner := "d1e6f196-fca3-48ad-8cd3-1a98e3bd46d2"
requestBody.SetOwner(&owner)
extensionSchemaProperty := graphmodels.NewExtensionSchemaProperty()
name := "courseId"
extensionSchemaProperty.SetName(&name)
type := "Integer"
extensionSchemaProperty.SetType(&type)
extensionSchemaProperty1 := graphmodels.NewExtensionSchemaProperty()
name := "courseName"
extensionSchemaProperty1.SetName(&name)
type := "String"
extensionSchemaProperty1.SetType(&type)
extensionSchemaProperty2 := graphmodels.NewExtensionSchemaProperty()
name := "courseType"
extensionSchemaProperty2.SetName(&name)
type := "String"
extensionSchemaProperty2.SetType(&type)
properties := []graphmodels.ExtensionSchemaPropertyable {
extensionSchemaProperty,
extensionSchemaProperty1,
extensionSchemaProperty2,
}
requestBody.SetProperties(properties)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schemaExtensions, err := graphClient.SchemaExtensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SchemaExtension schemaExtension = new SchemaExtension();
schemaExtension.setId("bellowscollege_courses");
schemaExtension.setDescription("Bellows College training courses extensions");
LinkedList<String> targetTypes = new LinkedList<String>();
targetTypes.add("Group");
schemaExtension.setTargetTypes(targetTypes);
schemaExtension.setOwner("d1e6f196-fca3-48ad-8cd3-1a98e3bd46d2");
LinkedList<ExtensionSchemaProperty> properties = new LinkedList<ExtensionSchemaProperty>();
ExtensionSchemaProperty extensionSchemaProperty = new ExtensionSchemaProperty();
extensionSchemaProperty.setName("courseId");
extensionSchemaProperty.setType("Integer");
properties.add(extensionSchemaProperty);
ExtensionSchemaProperty extensionSchemaProperty1 = new ExtensionSchemaProperty();
extensionSchemaProperty1.setName("courseName");
extensionSchemaProperty1.setType("String");
properties.add(extensionSchemaProperty1);
ExtensionSchemaProperty extensionSchemaProperty2 = new ExtensionSchemaProperty();
extensionSchemaProperty2.setName("courseType");
extensionSchemaProperty2.setType("String");
properties.add(extensionSchemaProperty2);
schemaExtension.setProperties(properties);
SchemaExtension result = graphClient.schemaExtensions().post(schemaExtension);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.schema_extension import SchemaExtension
from msgraph.generated.models.extension_schema_property import ExtensionSchemaProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SchemaExtension(
id = "bellowscollege_courses",
description = "Bellows College training courses extensions",
target_types = [
"Group",
],
owner = "d1e6f196-fca3-48ad-8cd3-1a98e3bd46d2",
properties = [
ExtensionSchemaProperty(
name = "courseId",
type = "Integer",
),
ExtensionSchemaProperty(
name = "courseName",
type = "String",
),
ExtensionSchemaProperty(
name = "courseType",
type = "String",
),
],
)
result = await graph_client.schema_extensions.post(request_body)
Na resposta, o estado inicial predefinido da extensão de esquema é InDevelopment. Enquanto estiver a desenvolver a extensão, pode mantê-la neste estado, durante a qual apenas a aplicação que a criou pode atualizá-la com alterações de aditivos ou eliminá-la. Quando estiver pronto para partilhar a extensão para utilização por outras aplicações, defina o estado como Disponível.
Etapa 3. Expandir um grupo com dados personalizados
Pode expandir um grupo com dados personalizados durante a criação do grupo ou ao atualizar um grupo existente.
Opção 1: Criar um novo grupo com dados expandidos
O pedido seguinte cria um novo grupo e utiliza a extensão de bellowscollege_courses esquema para expandir o grupo com dados personalizados. Se tiver um grupo existente, também pode expandi-lo com dados personalizados ao atualizar o grupo com os dados da extensão.
A resposta não reflete quaisquer extensões de dados. Tem de explicitamente $select a extensão por nome através de uma GET /group/{id} operação.
POST https://graph.microsoft.com/v1.0/groups
Content-type: application/json
{
"displayName": "New Managers March 2024",
"description": "New Managers training course for March 2024",
"groupTypes": [
"Unified"
],
"mailEnabled": true,
"mailNickname": "newMan202403",
"securityEnabled": false,
"bellowscollege_courses": {
"courseId": "123",
"courseName": "New Managers",
"courseType": "Online"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new Group
{
DisplayName = "New Managers March 2024",
Description = "New Managers training course for March 2024",
GroupTypes = new List<string>
{
"Unified",
},
MailEnabled = true,
MailNickname = "newMan202403",
SecurityEnabled = false,
AdditionalData = new Dictionary<string, object>
{
{
"bellowscollege_courses" , new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"courseId", new UntypedString("123")
},
{
"courseName", new UntypedString("New Managers")
},
{
"courseType", new UntypedString("Online")
},
})
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.PostAsync(requestBody);
mgc groups create --body '{\
"displayName": "New Managers March 2024",\
"description": "New Managers training course for March 2024",\
"groupTypes": [\
"Unified"\
],\
"mailEnabled": true,\
"mailNickname": "newMan202403",\
"securityEnabled": false,\
"bellowscollege_courses": {\
"courseId": "123",\
"courseName": "New Managers",\
"courseType": "Online"\
}\
}\
'
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
group.setDisplayName("New Managers March 2024");
group.setDescription("New Managers training course for March 2024");
LinkedList<String> groupTypes = new LinkedList<String>();
groupTypes.add("Unified");
group.setGroupTypes(groupTypes);
group.setMailEnabled(true);
group.setMailNickname("newMan202403");
group.setSecurityEnabled(false);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
bellowscollegeCourses = new ();
bellowscollegeCourses.setCourseId("123");
bellowscollegeCourses.setCourseName("New Managers");
bellowscollegeCourses.setCourseType("Online");
additionalData.put("bellowscollege_courses", bellowscollegeCourses);
group.setAdditionalData(additionalData);
Group result = graphClient.groups().post(group);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.group import Group
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Group(
display_name = "New Managers March 2024",
description = "New Managers training course for March 2024",
group_types = [
"Unified",
],
mail_enabled = True,
mail_nickname = "newMan202403",
security_enabled = False,
additional_data = {
"bellowscollege_courses" : {
"course_id" : "123",
"course_name" : "New Managers",
"course_type" : "Online",
},
}
)
result = await graph_client.groups.post(request_body)
O exemplo a seguir mostra a resposta. A resposta não inclui a nova extensão. Tem de explicitamente $select a extensão por nome através de uma GET /group/{id} operação.
Observação: o objeto de resposta mostrado aqui pode ser encurtado para legibilidade.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups/$entity",
"id": "8fb45944-4085-449f-b95d-f7dd74a1b081",
"createdDateTime": "2024-01-24T09:09:03Z",
"description": "New Managers training course for March 2024",
"displayName": "New Managers March 2024",
"groupTypes": [
"Unified"
],
"mail": "newMan202403@bellowscollege.com",
"mailEnabled": true,
"mailNickname": "newMan202403"
}
Opção 2: atualizar um grupo existente com dados expandidos
Se tiver um grupo existente, também pode expandi-lo com dados personalizados da seguinte forma. O pedido devolve uma 204 No Content resposta.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new Group
{
AdditionalData = new Dictionary<string, object>
{
{
"bellowscollege_courses" , new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"courseId", new UntypedString("123")
},
{
"courseName", new UntypedString("New Managers")
},
{
"courseType", new UntypedString("Online")
},
})
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroup()
additionalData := map[string]interface{}{
bellowscollege_courses := graph.New()
courseId := "123"
bellowscollege_courses.SetCourseId(&courseId)
courseName := "New Managers"
bellowscollege_courses.SetCourseName(&courseName)
courseType := "Online"
bellowscollege_courses.SetCourseType(&courseType)
requestBody.SetBellowscollege_courses(bellowscollege_courses)
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().ByGroupId("group-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
bellowscollegeCourses = new ();
bellowscollegeCourses.setCourseId("123");
bellowscollegeCourses.setCourseName("New Managers");
bellowscollegeCourses.setCourseType("Online");
additionalData.put("bellowscollege_courses", bellowscollegeCourses);
group.setAdditionalData(additionalData);
Group result = graphClient.groups().byGroupId("{group-id}").patch(group);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.group import Group
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Group(
additional_data = {
"bellowscollege_courses" : {
"course_id" : "123",
"course_name" : "New Managers",
"course_type" : "Online",
},
}
)
result = await graph_client.groups.by_group_id('group-id').patch(request_body)
O pedido seguinte atualiza a propriedade courseType na bellowscollege_courses extensão do grupo para Hybrid. Embora pretenda atualizar apenas a propriedade courseType , também tem de incluir as outras propriedades e os respetivos valores existentes no corpo do pedido. Caso contrário, o Microsoft Graph define-os como null e remove os respetivos dados.
O pedido seguinte devolve uma 204 No Content resposta.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new Group
{
AdditionalData = new Dictionary<string, object>
{
{
"bellowscollege_courses" , new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"courseId", new UntypedString("123")
},
{
"courseName", new UntypedString("New Managers")
},
{
"courseType", new UntypedString("Hybrid")
},
})
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroup()
additionalData := map[string]interface{}{
bellowscollege_courses := graph.New()
courseId := "123"
bellowscollege_courses.SetCourseId(&courseId)
courseName := "New Managers"
bellowscollege_courses.SetCourseName(&courseName)
courseType := "Hybrid"
bellowscollege_courses.SetCourseType(&courseType)
requestBody.SetBellowscollege_courses(bellowscollege_courses)
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().ByGroupId("group-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
bellowscollegeCourses = new ();
bellowscollegeCourses.setCourseId("123");
bellowscollegeCourses.setCourseName("New Managers");
bellowscollegeCourses.setCourseType("Hybrid");
additionalData.put("bellowscollege_courses", bellowscollegeCourses);
group.setAdditionalData(additionalData);
Group result = graphClient.groups().byGroupId("{group-id}").patch(group);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.group import Group
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Group(
additional_data = {
"bellowscollege_courses" : {
"course_id" : "123",
"course_name" : "New Managers",
"course_type" : "Hybrid",
},
}
)
result = await graph_client.groups.by_group_id('group-id').patch(request_body)
Etapa 5. Obter um grupo e os respetivos dados de extensão
Para obter os dados personalizados num grupo, utilize $select para incluir a extensão por nome.
Para além da filtragem pelo ID da extensão de esquema, também pode filtrar pelos valores de propriedade da extensão. O exemplo seguinte procura o grupo que tem a bellowscollege_courses extensão com um courseId valor de propriedade correspondente 123e obtém os dados da extensão e as propriedades displayName, id e description do grupo.
GET https://graph.microsoft.com/v1.0/groups?$filter=bellowscollege_courses/courseId eq '123'&$select=displayName,id,description,bellowscollege_courses
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "bellowscollege_courses/courseId eq '123'";
requestConfiguration.QueryParameters.Select = new string []{ "displayName","id","description","bellowscollege_courses" };
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphgroups "github.com/microsoftgraph/msgraph-sdk-go/groups"
//other-imports
)
requestFilter := "bellowscollege_courses/courseId eq '123'"
requestParameters := &graphgroups.GroupsRequestBuilderGetQueryParameters{
Filter: &requestFilter,
Select: [] string {"displayName","id","description","bellowscollege_courses"},
}
configuration := &graphgroups.GroupsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.groups().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "bellowscollege_courses/courseId eq '123'";
requestConfiguration.queryParameters.select = new String []{"displayName", "id", "description", "bellowscollege_courses"};
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters(
filter = "bellowscollege_courses/courseId eq '123'",
select = ["displayName","id","description","bellowscollege_courses"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.groups.get(request_configuration = request_configuration)
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups(displayName,id,description,bellowscollege_courses)",
"value": [
{
"displayName": "New Managers March 2024",
"id": "8fb45944-4085-449f-b95d-f7dd74a1b081",
"description": "New Managers training course for March 2024",
"bellowscollege_courses": {
"@odata.type": "#microsoft.graph.ComplexExtensionValue",
"courseType": "Hybrid",
"courseName": "New Managers",
"courseId": 123
}
}
]
}
Passo 6: Eliminar os dados da extensão e a definição da extensão de esquema
Pode eliminar uma definição de extensão de esquema se já não precisar dela. Se as instâncias de recursos tiverem a propriedade de extensão aplicada, a eliminação da definição da extensão de esquema não elimina os dados da extensão nas instâncias de recursos. Em vez disso, os dados da extensão estão disponíveis, mas já não estão acessíveis. Pode recriar a definição da extensão de esquema com a mesma configuração – se utilizou o domínio verificado para o ID da extensão de esquema – para poder eliminar os dados da extensão.
O pedido seguinte elimina a propriedade da bellowscollege_courses extensão de esquema e os respetivos dados associados do grupo. O pedido devolve uma 204 No Content resposta.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Group
{
AdditionalData = new Dictionary<string, object>
{
{
"bellowscollege_courses" , null
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroup()
additionalData := map[string]interface{}{
bellowscollege_courses := null
requestBody.SetBellowscollege_courses(&bellowscollege_courses)
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groups, err := graphClient.Groups().ByGroupId("group-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Group group = new Group();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("bellowscollege_courses", null);
group.setAdditionalData(additionalData);
Group result = graphClient.groups().byGroupId("{group-id}").patch(group);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.group import Group
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Group(
additional_data = {
"bellowscollege_courses" : None,
}
)
result = await graph_client.groups.by_group_id('group-id').patch(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.SchemaExtensions["{schemaExtension-id}"].DeleteAsync();
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.SchemaExtensions().BySchemaExtensionId("schemaExtension-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.schemaExtensions().bySchemaExtensionId("{schemaExtension-id}").delete();
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->schemaExtensions()->bySchemaExtensionId('schemaExtension-id')->delete()->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.schema_extensions.by_schema_extension_id('schemaExtension-id').delete()