https://github.com/permitio/permit-cpp
https://github.com/permitio/permit-cpp
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/permitio/permit-cpp
- Owner: permitio
- License: apache-2.0
- Created: 2023-01-31T13:25:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-09T11:16:51.000Z (over 1 year ago)
- Last Synced: 2025-05-11T07:13:27.002Z (about 1 year ago)
- Language: C++
- Size: 231 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Permit C++ SDK
#
Permit.io API
- API version: 2.0.0
Authorization as a service
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
## Requirements
Building the API client library requires:
1. CMake 3.2+
2. Qt
3. C++ Compiler
## Getting Started
example.h:
```c++
#include
#include "../client/OAIAPIKeysApi.h"
using namespace test_namespace;
class Example : public QObject {
Q_OBJECT
OAIAPIKeyCreate create();
public slots:
void exampleFunction1();
};
```
example.cpp:
```c++
#include "../client/OAIAPIKeysApi.h"
#include "example.h"
#include
#include
OAIAPIKeyCreate Example::create(){
OAIAPIKeyCreate obj;
return obj;
}
void Example::exampleFunction1(){
OAIAPIKeysApi apiInstance;
// Configure HTTP bearer authorization: HTTPBearer
apiInstance.setBearerToken("BEARER TOKEN");
QEventLoop loop;
connect(&apiInstance, &OAIAPIKeysApi::createApiKeySignal, [&]() {
loop.quit();
});
connect(&apiInstance, &OAIAPIKeysApi::createApiKeySignalE, [&](QNetworkReply::NetworkError, QString error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
loop.quit();
});
OAIAPIKeyCreate oaiapi_key_create = create(); // OAIAPIKeyCreate |
apiInstance.createApiKey(oaiapi_key_create);
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
loop.exec();
}
```
## Documentation for Servers
Parameterized Servers are supported. Define a server in the API for each endpoint with arbitrary numbers of variables:
```yaml
servers:
- url: http://{server}:{port}/{basePath}
description: Description of the Server
variables:
server:
enum:
- 'petstore'
- 'qa-petstore'
- 'dev-petstore'
default: 'petstore'
port:
enum:
- '3000'
- '1000'
default: '3000'
basePath:
default: v1
```
To change the default variable, use this function in each Api:
```c++
int setDefaultServerValue(int serverIndex,const QString &operation, const QString &variable,const QString &val);
```
The parameter "serverIndex" will choose a server from the server list for each endpoint. There is always at least one server with index 0. The Parameter "operation" should be the desired endpoint operationid.
Variable is the name of the variable you wish to change and the value is the new default Value.
The function will return -1 when the variable does not exists, -2 if value is not defined in the variable enum and -3 if the operation is not found.
If your endpoint has multiple server objects in the servers array, you can set the server that will be used with this function:
```c++
void setServerIndex(const QString &operation, int serverIndex);
```
Parameter "operation" should be your operationid. "serverIndex" is the index you want to set as your default server. The function will check if there is a server with your index.
Here is an example of multiple servers in the servers array. The first server will have index 0 and the second will have index 1.
```yaml
servers:
- url: http://{server}:8080/
description: Description of the Server
variables:
server:
enum:
- 'petstore'
- 'qa-petstore'
- 'dev-petstore'
default: 'petstore'
- url: https://localhost:8080/v1
```
## Documentation for Authorization
Authentication schemes defined for the API:
### HTTPBearer
- **Type**: HTTP Bearer Token authentication
## Author
## License
for more information visit []()