You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. syntax = "proto3";
  20. package kiapi.common;
  21. import "google/protobuf/any.proto";
  22. enum ApiStatusCode
  23. {
  24. AS_UNKNOWN = 0;
  25. AS_OK = 1; // Request succeeded
  26. AS_TIMEOUT = 2; // Request timed out
  27. AS_BAD_REQUEST = 3; // The request had invalid parameters or otherwise was illegal
  28. AS_NOT_READY = 4; // KiCad was not (yet) in a state where it could handle API requests
  29. AS_UNHANDLED = 5; // The request was not handled by KiCad
  30. AS_TOKEN_MISMATCH = 6; // The kicad_token in the request didn't match this KiCad's token
  31. }
  32. /*
  33. * For future expansion: any header fields that should be sent with a request
  34. */
  35. message ApiRequestHeader
  36. {
  37. // An opaque string identifying a running instance of KiCad. If this is set to a non-empty
  38. // string in an API request, KiCad will reject the request if the value doesn't match its own
  39. // token. This can be used to let API clients make sure they are still talking to the same
  40. // instance of KiCad if they are long-running.
  41. string kicad_token = 1;
  42. // A string identifying an API client. Should be set by the client to a value that is unique
  43. // to a specific instance of a client, for example the package name of the client plus its
  44. // process ID or a random string, e.g. "com.github.me.my_awesome_plugin-73951". The main purpose
  45. // of this name is to identify the client in debug logs.
  46. string client_name = 2;
  47. }
  48. /*
  49. * The top-level envelope container for an API request (message from a client to the KiCad API server)
  50. */
  51. message ApiRequest
  52. {
  53. ApiRequestHeader header = 1;
  54. google.protobuf.Any message = 2;
  55. }
  56. /*
  57. * For future expansion: any header fields that should be sent with a response
  58. */
  59. message ApiResponseHeader
  60. {
  61. /// An opaque string identifying a running instance of KiCad.
  62. string kicad_token = 1;
  63. }
  64. message ApiResponse
  65. {
  66. ApiResponseHeader header = 1;
  67. ApiResponseStatus status = 2;
  68. google.protobuf.Any message = 3;
  69. }
  70. message ApiResponseStatus
  71. {
  72. /// A code describing the category of error (or AS_OK if no error)
  73. ApiStatusCode status = 1;
  74. /// A human-readable description of the error, if any
  75. string error_message = 2;
  76. }