Share via


EasmClient.CreateOrReplaceDiscoveryGroupAsync Method

Definition

Overloads

CreateOrReplaceDiscoveryGroupAsync(String, DiscoveryGroupPayload, CancellationToken)

Create a discovery group with a given groupName.

CreateOrReplaceDiscoveryGroupAsync(String, RequestContent, RequestContext)

[Protocol Method] Create a discovery group with a given groupName.

CreateOrReplaceDiscoveryGroupAsync(String, DiscoveryGroupPayload, CancellationToken)

Source:
EasmClient.cs

Create a discovery group with a given groupName.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.DiscoveryGroup>> CreateOrReplaceDiscoveryGroupAsync (string groupName, Azure.Analytics.Defender.Easm.DiscoveryGroupPayload discoveryGroupPayload, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrReplaceDiscoveryGroupAsync : string * Azure.Analytics.Defender.Easm.DiscoveryGroupPayload * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.DiscoveryGroup>>
override this.CreateOrReplaceDiscoveryGroupAsync : string * Azure.Analytics.Defender.Easm.DiscoveryGroupPayload * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.DiscoveryGroup>>
Public Overridable Function CreateOrReplaceDiscoveryGroupAsync (groupName As String, discoveryGroupPayload As DiscoveryGroupPayload, Optional cancellationToken As CancellationToken = Nothing) As Task(Of 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 CreateOrReplaceDiscoveryGroupAsync.

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 = await client.CreateOrReplaceDiscoveryGroupAsync("<groupName>", discoveryGroupPayload);

This sample shows how to call CreateOrReplaceDiscoveryGroupAsync 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 = await client.CreateOrReplaceDiscoveryGroupAsync("<groupName>", discoveryGroupPayload);

Applies to

CreateOrReplaceDiscoveryGroupAsync(String, RequestContent, RequestContext)

Source:
EasmClient.cs

[Protocol Method] Create a discovery group with a given groupName.

public virtual System.Threading.Tasks.Task<Azure.Response> CreateOrReplaceDiscoveryGroupAsync (string groupName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrReplaceDiscoveryGroupAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.CreateOrReplaceDiscoveryGroupAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function CreateOrReplaceDiscoveryGroupAsync (groupName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of 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 CreateOrReplaceDiscoveryGroupAsync 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 = await client.CreateOrReplaceDiscoveryGroupAsync("<groupName>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());

This sample shows how to call CreateOrReplaceDiscoveryGroupAsync 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 = await client.CreateOrReplaceDiscoveryGroupAsync("<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