EasmClient.CreateOrReplaceDiscoveryGroup Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateOrReplaceDiscoveryGroup(String, RequestContent, RequestContext) |
[Protocol Method] Create a discovery group with a given groupName.
|
CreateOrReplaceDiscoveryGroup(String, DiscoveryGroupPayload, CancellationToken) |
Create a discovery group with a given groupName. |
CreateOrReplaceDiscoveryGroup(String, RequestContent, RequestContext)
- Source:
- EasmClient.cs
[Protocol Method] Create a discovery group with a given groupName.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler CreateOrReplaceDiscoveryGroup(String, DiscoveryGroupPayload, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Response CreateOrReplaceDiscoveryGroup(string groupName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrReplaceDiscoveryGroup : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.CreateOrReplaceDiscoveryGroup : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function CreateOrReplaceDiscoveryGroup (groupName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response
Parameters
- groupName
- String
The caller provided unique name for the resource.
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
groupName
or content
is null.
groupName
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call CreateOrReplaceDiscoveryGroup and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new object());
Response response = client.CreateOrReplaceDiscoveryGroup("<groupName>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());
This sample shows how to call CreateOrReplaceDiscoveryGroup with all parameters and request content and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
name = "<name>",
description = "<description>",
tier = "<tier>",
frequencyMilliseconds = 1234L,
seeds = new object[]
{
new
{
kind = "as",
name = "<name>",
}
},
names = new object[]
{
"<names>"
},
excludes = new object[]
{
null
},
templateId = "<templateId>",
});
Response response = client.CreateOrReplaceDiscoveryGroup("<groupName>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("tier").ToString());
Console.WriteLine(result.GetProperty("frequencyMilliseconds").ToString());
Console.WriteLine(result.GetProperty("seeds")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("seeds")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("names")[0].ToString());
Console.WriteLine(result.GetProperty("excludes")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("excludes")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("submittedDate").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("startedDate").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("completedDate").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("tier").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("totalAssetsFoundCount").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("seeds")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("seeds")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("excludes")[0].GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("excludes")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("latestRun").GetProperty("names")[0].ToString());
Console.WriteLine(result.GetProperty("createdDate").ToString());
Console.WriteLine(result.GetProperty("templateId").ToString());
Applies to
CreateOrReplaceDiscoveryGroup(String, DiscoveryGroupPayload, CancellationToken)
- Source:
- EasmClient.cs
Create a discovery group with a given groupName.
public virtual Azure.Response<Azure.Analytics.Defender.Easm.DiscoveryGroup> CreateOrReplaceDiscoveryGroup(string groupName, Azure.Analytics.Defender.Easm.DiscoveryGroupPayload discoveryGroupPayload, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrReplaceDiscoveryGroup : string * Azure.Analytics.Defender.Easm.DiscoveryGroupPayload * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.DiscoveryGroup>
override this.CreateOrReplaceDiscoveryGroup : string * Azure.Analytics.Defender.Easm.DiscoveryGroupPayload * System.Threading.CancellationToken -> Azure.Response<Azure.Analytics.Defender.Easm.DiscoveryGroup>
Public Overridable Function CreateOrReplaceDiscoveryGroup (groupName As String, discoveryGroupPayload As DiscoveryGroupPayload, Optional cancellationToken As CancellationToken = Nothing) As Response(Of DiscoveryGroup)
Parameters
- groupName
- String
The caller provided unique name for the resource.
- discoveryGroupPayload
- DiscoveryGroupPayload
A request body used to create a discovery group.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
groupName
or discoveryGroupPayload
is null.
groupName
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call CreateOrReplaceDiscoveryGroup.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
DiscoveryGroupPayload discoveryGroupPayload = new DiscoveryGroupPayload();
Response<DiscoveryGroup> response = client.CreateOrReplaceDiscoveryGroup("<groupName>", discoveryGroupPayload);
This sample shows how to call CreateOrReplaceDiscoveryGroup with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
DiscoveryGroupPayload discoveryGroupPayload = new DiscoveryGroupPayload
{
Name = "<name>",
Description = "<description>",
Tier = "<tier>",
FrequencyMilliseconds = 1234L,
Seeds = {new DiscoverySource
{
Kind = DiscoverySourceKind.As,
Name = "<name>",
}},
Names = { "<names>" },
Excludes = { default },
TemplateId = "<templateId>",
};
Response<DiscoveryGroup> response = client.CreateOrReplaceDiscoveryGroup("<groupName>", discoveryGroupPayload);
Applies to
Azure SDK for .NET