Registering an API and Authorizing the API to an App
Function
This API is used to register an API and authorize the API to an App. Only Huawei Cloud users who have the permission to update the service can call this API.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
POST /v1/{project_id}/services/{service_id}/app-auth-api
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details, see Obtaining a Project ID and Name. |
service_id |
Yes |
String |
Service ID, which can be obtained by querying services |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
apps |
Yes |
Array of Apps objects |
App list |
workspace_id |
No |
String |
Workspace ID. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
X-Request-Id |
String |
Link trace ID |
Parameter |
Type |
Description |
---|---|---|
api |
AuthTypeApiBasicInfo object |
API details. |
auth_result |
Array of AppAuthResultInfo objects |
Authorization result. |
Parameter |
Type |
Description |
---|---|---|
api_id |
String |
API ID |
api_method |
String |
Request method, which can be GET, POST, PUT, DELETE, HEAD, PATCH, OPTIONS, or ANY. ANY is the default value. |
api_name |
String |
API name |
api_remark |
String |
API description. The value contains a maximum of 255 characters. |
auth_type |
String |
API authentication mode. The options are: Enums:
|
predict_url |
String |
Prediction URL |
service_id |
String |
Service ID |
service_name |
String |
Service name |
support_app_code |
Boolean |
Whether to support the App code |
Parameter |
Type |
Description |
---|---|---|
api_id |
String |
API ID |
app_id |
String |
App ID, which can be obtained by querying apps |
auth_id |
String |
Authorization ID, which is empty if the authorization fails |
reason |
String |
Authorization or authorization cancellation failure reason, which is empty if the authorization is successful |
success |
Boolean |
Whether authorization or authorization cancellation is successful |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
X-Request-Id |
String |
Link trace ID |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error codes of ModelArts. |
error_msg |
String |
Error message. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
X-Request-Id |
String |
Link trace ID |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error codes of ModelArts. |
error_msg |
String |
Error message. |
Status code: 403
Parameter |
Type |
Description |
---|---|---|
X-Request-Id |
String |
Link trace ID |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error codes of ModelArts. |
error_msg |
String |
Error message. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
X-Request-Id |
String |
Link trace ID |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error codes of ModelArts. |
error_msg |
String |
Error message. |
Example Requests
Creating an API and authorizing an App
POST https://{endpoint}/v1/{project_id}/services/{service_id}/app-auth-api { "apps" : [ { "app_id" : "e2fb64be3be9418bb0f570c60f0ed93f" } ] }
Example Responses
Status code: 200
OK
{ "api" : { "api_id" : "b9c78dbb50d04230aab90e35e141fccf", "api_name" : "infer_456963f1737c4de08bee5b4f6f3a8fa3", "api_method" : "ANY", "predict_url" : "https://d566c7efafe04a26a83d3a8475602ee3.apig.xxxxxx.com/v1/infers/456963f1-737c-4de0-8bee-5b4f6f3a8fa3", "support_app_code" : true, "service_id" : "456963f1-737c-4de0-8bee-5b4f6f3a8fa3", "service_name" : "service-129c-test" }, "auth_result" : [ { "api_id" : "b9c78dbb50d04230aab90e35e141fccf", "app_id" : "e2fb64be3be9418bb0f570c60f0ed93f", "success" : true } ] }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
401 |
Unauthorized |
403 |
Forbidden |
500 |
Server Internal Error |
Error Codes
See Error Codes.
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.
For any further questions, feel free to contact us through the chatbot.
Chatbot