Deletes a business scenario using the AI Guardrails SDK for .NET. Before deleting, make sure the business scenario is not actively used. Deleting an active business scenario disables its customized moderation policy and falls back to the default policy, which may cause moderation errors on your data.
For parameter details, see DeleteBizType.
Prerequisites
Before you begin, ensure that you have:
Installed the .NET dependencies using the required .NET version. For instructions, see Install .NET dependencies.
Using an unsupported .NET version causes subsequent operation calls to fail.
Delete a business scenario
| Operation | Description | Supported regions |
|---|---|---|
| DeleteBizType | Deletes a business scenario. | cn-shanghai (China (Shanghai)), cn-beijing (China (Beijing)), cn-shenzhen (China (Shenzhen)), ap-southeast-1 (Singapore) |
Sample code
The following example deletes a business scenario by calling DeleteBizType. Load your AccessKey ID and AccessKey secret from environment variables to avoid exposing credentials in your code.
using System;
using Newtonsoft.Json;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Green.Model.V20170823;
using System.Collections.Generic;
namespace csharp_sdk_sample
{
class Program
{
static void Main(string[] args)
{
/**
* Common ways to obtain environment variables:
* Obtain the AccessKey ID of your RAM user: Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_ID");
* Obtain the AccessKey secret of your RAM user: Environment.GetEnvironmentVariable("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
*/
DefaultProfile profile = DefaultProfile.GetProfile(
"cn-shanghai",
"We recommend that you obtain the AccessKey ID of your RAM user from environment variables",
"We recommend that you obtain the AccessKey secret of your RAM user from environment variables");
DefaultAcsClient client = new DefaultAcsClient(profile);
DeleteBizTypeRequest deleteBizTypeRequest = new DeleteBizTypeRequest();
// Specify the name of the business scenario that you want to delete.
deleteBizTypeRequest.BizTypeName = "Name of the business scenario to be deleted";
// Specify the response format of the operation.
deleteBizTypeRequest.AcceptFormat = FormatType.JSON;
// Specify the request method.
deleteBizTypeRequest.Method = MethodType.POST;
deleteBizTypeRequest.Encoding = "utf-8";
try
{
DeleteBizTypeResponse response = client.GetAcsResponse(deleteBizTypeRequest);
if (response.HttpResponse.Status != 200)
{
Console.WriteLine("the request failed. status:{0}", response.HttpResponse.Status);
}
Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
}
catch (Exception ex)
{
Console.WriteLine("Failed with error info: {0}", ex.Message);
}
}
}
}该文章对您有帮助吗?