http_api.hrl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. %%--------------------------------------------------------------------
  2. %% Copyright (c) 2017-2024 EMQ Technologies Co., Ltd. All Rights Reserved.
  3. %%
  4. %% Licensed under the Apache License, Version 2.0 (the "License");
  5. %% you may not use this file except in compliance with the License.
  6. %% You may obtain a copy of the License at
  7. %%
  8. %% http://www.apache.org/licenses/LICENSE-2.0
  9. %%
  10. %% Unless required by applicable law or agreed to in writing, software
  11. %% distributed under the License is distributed on an "AS IS" BASIS,
  12. %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. %% See the License for the specific language governing permissions and
  14. %% limitations under the License.
  15. %%--------------------------------------------------------------------
  16. %% HTTP API Auth
  17. -define(BAD_USERNAME_OR_PWD, 'BAD_USERNAME_OR_PWD').
  18. -define(BAD_API_KEY_OR_SECRET, 'BAD_API_KEY_OR_SECRET').
  19. -define(API_KEY_NOT_ALLOW, 'API_KEY_NOT_ALLOW').
  20. -define(API_KEY_NOT_ALLOW_MSG, <<"This API Key don't have permission to access this resource">>).
  21. %% Bad Request
  22. -define(BAD_REQUEST, 'BAD_REQUEST').
  23. -define(NOT_MATCH, 'NOT_MATCH').
  24. -define(ALREADY_EXISTS, 'ALREADY_EXISTS').
  25. -define(BAD_CONFIG_SCHEMA, 'BAD_CONFIG_SCHEMA').
  26. -define(BAD_LISTENER_ID, 'BAD_LISTENER_ID').
  27. -define(BAD_NODE_NAME, 'BAD_NODE_NAME').
  28. -define(BAD_RPC, 'BAD_RPC').
  29. -define(BAD_TOPIC, 'BAD_TOPIC').
  30. -define(EXCEED_LIMIT, 'EXCEED_LIMIT').
  31. -define(INVALID_PARAMETER, 'INVALID_PARAMETER').
  32. -define(CONFLICT, 'CONFLICT').
  33. -define(NO_DEFAULT_VALUE, 'NO_DEFAULT_VALUE').
  34. -define(DEPENDENCY_EXISTS, 'DEPENDENCY_EXISTS').
  35. -define(MESSAGE_ID_SCHEMA_ERROR, 'MESSAGE_ID_SCHEMA_ERROR').
  36. -define(INVALID_ID, 'INVALID_ID').
  37. %% Resource Not Found
  38. -define(NOT_FOUND, 'NOT_FOUND').
  39. -define(CLIENTID_NOT_FOUND, 'CLIENTID_NOT_FOUND').
  40. -define(CLIENT_NOT_FOUND, 'CLIENT_NOT_FOUND').
  41. -define(MESSAGE_ID_NOT_FOUND, 'MESSAGE_ID_NOT_FOUND').
  42. -define(RESOURCE_NOT_FOUND, 'RESOURCE_NOT_FOUND').
  43. -define(TOPIC_NOT_FOUND, 'TOPIC_NOT_FOUND').
  44. -define(USER_NOT_FOUND, 'USER_NOT_FOUND').
  45. %% Internal error
  46. -define(INTERNAL_ERROR, 'INTERNAL_ERROR').
  47. -define(SERVICE_UNAVAILABLE, 'SERVICE_UNAVAILABLE').
  48. -define(SOURCE_ERROR, 'SOURCE_ERROR').
  49. -define(UPDATE_FAILED, 'UPDATE_FAILED').
  50. -define(REST_FAILED, 'REST_FAILED').
  51. -define(CLIENT_NOT_RESPONSE, 'CLIENT_NOT_RESPONSE').
  52. %% All codes
  53. -define(ERROR_CODES, [
  54. {?BAD_USERNAME_OR_PWD, <<"Bad username or password">>},
  55. {?BAD_API_KEY_OR_SECRET, <<"Bad API key or secret">>},
  56. {'BAD_REQUEST', <<"Request parameters are invalid">>},
  57. {'NOT_MATCH', <<"Conditions are not matched">>},
  58. {'ALREADY_EXISTS', <<"Resource already existed">>},
  59. {'BAD_CONFIG_SCHEMA', <<"Configuration data is invalid">>},
  60. {'BAD_LISTENER_ID', <<"Bad listener ID">>},
  61. {'BAD_NODE_NAME', <<"Bad Node Name">>},
  62. {'BAD_RPC', <<"RPC Failed. Check the cluster status and the requested node status">>},
  63. {'BAD_TOPIC', <<"Topic syntax error, Topic needs to comply with the MQTT protocol standard">>},
  64. {'EXCEED_LIMIT', <<"Create resources that exceed the maximum limit or minimum limit">>},
  65. {'INVALID_PARAMETER', <<"Request parameters is invalid and exceeds the boundary value">>},
  66. {'CONFLICT', <<"Conflicting request resources">>},
  67. {'NO_DEFAULT_VALUE', <<"Request parameters do not use default values">>},
  68. {'DEPENDENCY_EXISTS', <<"Resource is dependent by another resource">>},
  69. {'MESSAGE_ID_SCHEMA_ERROR', <<"Message ID parsing error">>},
  70. {'INVALID_ID', <<"Bad ID schema">>},
  71. {'MESSAGE_ID_NOT_FOUND', <<"Message ID does not exist">>},
  72. {'NOT_FOUND', <<"Resource was not found or does not exist">>},
  73. {'CLIENTID_NOT_FOUND', <<"Client ID was not found or does not exist">>},
  74. {'CLIENT_NOT_FOUND', <<"Client was not found or does not exist(usually not a MQTT client)">>},
  75. {'RESOURCE_NOT_FOUND', <<"Resource not found">>},
  76. {'TOPIC_NOT_FOUND', <<"Topic not found">>},
  77. {'USER_NOT_FOUND', <<"User not found">>},
  78. {'INTERNAL_ERROR', <<"Server inter error">>},
  79. {'SERVICE_UNAVAILABLE', <<"Service unavailable">>},
  80. {'SOURCE_ERROR', <<"Source error">>},
  81. {'UPDATE_FAILED', <<"Update failed">>},
  82. {'REST_FAILED', <<"Reset source or config failed">>},
  83. {'CLIENT_NOT_RESPONSE', <<"Client not responding">>}
  84. ]).