El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.
ImageSearch
ImageSearch
- What's New
- Service Overview
- Getting Started
- API Reference
- SDK Reference
- FAQs
- General Reference
On this page
Show all
Copied.
Creating an Instance
This section describes how to create an instance using AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. Set the Name and Model parameters in the initialized CreateInstanceReq command to configure the instance name and model. After the configuration is complete, run the code.
- The sample code for creating an instance is as follows:
using System; using System.Collections.Generic; using HuaweiCloud.SDK.Core; using HuaweiCloud.SDK.Core.Auth; using HuaweiCloud.SDK.ImageSearch; using HuaweiCloud.SDK.ImageSearch.V1; using HuaweiCloud.SDK.ImageSearch.V1.Model; using Newtonsoft.Json; namespace RunCreateInstanceSolution { class Program { static void Main(string[] args) { const string ak = "<YOUR AK>"; const string sk = "<YOUR SK>"; var config = HttpConfig.GetDefaultConfig(); config.IgnoreSslVerification = true; var auth = new BasicCredentials(ak, sk); var client = ImageSearchClient.NewBuilder() .WithCredential(auth) .WithRegion(ImageSearchRegion.ValueOf("cn-north-4")) .WithHttpConfig(config) .Build(); var req = new RunCreateInstanceRequest { }; req.Body = new CreateInstanceReq() { Name = "instance-name", Model = "common-search", Tags = new List<string>{"animal", "plant"} }; try { var resp = client.RunCreateInstance(req); var respStatusCode = resp.HttpStatusCode; Console.WriteLine(respStatusCode); Console.WriteLine(JsonConvert.DeserializeObject(resp.HttpBody)); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } } } }
- Execute the sample code. If 200 is displayed on the console, the code is successfully executed. For details, see Creating an Instance.
200 { "instanceName": "instance-name", "level": 30000000, "expiredDate": -1, "domain": "general image search", "desc": "", "registerDate": 1638939677331, "tags"[ "animal", "plant" ], "status": "NORMAL" }
Parent topic: Using the .NET SDK
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot