mirror of
https://github.com/unraid/api.git
synced 2026-01-01 14:10:10 -06:00
feat: add description flag, remove console log, and update readme
This commit is contained in:
@@ -39,24 +39,56 @@ Options:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Key
|
||||||
|
|
||||||
|
To get an existing API key, run:
|
||||||
|
|
||||||
|
```
|
||||||
|
unraid-api key get --name "my-app-key"
|
||||||
|
```
|
||||||
|
|
||||||
|
To get an API key, and create if it doesn't exist, run:
|
||||||
|
|
||||||
|
```
|
||||||
|
unraid-api key get --name "my-app-key" --create
|
||||||
|
```
|
||||||
|
|
||||||
|
To create a new API key with specific roles, run:
|
||||||
|
|
||||||
|
```
|
||||||
|
unraid-api key create --name "backup-app" --roles "admin,guest"
|
||||||
|
```
|
||||||
|
|
||||||
|
To create a new API key with roles and permissions, run:
|
||||||
|
|
||||||
|
```
|
||||||
|
unraid-api key create --name "backup-app" --roles "admin,guest" --permissions "read:any"
|
||||||
|
```
|
||||||
|
|
||||||
## Report
|
## Report
|
||||||
|
|
||||||
To view the current status of the unraid-api and its connection to mothership, run:
|
To view the current status of the unraid-api and its connection to mothership, run:
|
||||||
|
|
||||||
```
|
```
|
||||||
unraid-api report
|
unraid-api report
|
||||||
```
|
```
|
||||||
|
|
||||||
To view verbose data (anonymized), run:
|
To view verbose data (anonymized), run:
|
||||||
|
|
||||||
```
|
```
|
||||||
unraid-api report -v
|
unraid-api report -v
|
||||||
```
|
```
|
||||||
|
|
||||||
To view non-anonymized verbose data, run:
|
To view non-anonymized verbose data, run:
|
||||||
|
|
||||||
```
|
```
|
||||||
unraid-api report -vv
|
unraid-api report -vv
|
||||||
```
|
```
|
||||||
|
|
||||||
## Secrets
|
## Secrets
|
||||||
|
|
||||||
If you found this file you're likely a developer. If you'd like to know more about the API and when it's available please join [our discord](https://discord.unraid.net/).
|
If you found this file you're likely a developer. If you'd like to know more about the API and when it's available please join [our discord](https://discord.unraid.net/).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright Lime Technology Inc. All rights reserved.
|
Copyright Lime Technology Inc. All rights reserved.
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ enum Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KeyFlags = {
|
type KeyFlags = {
|
||||||
command: string;
|
|
||||||
name: string;
|
|
||||||
create?: boolean;
|
create?: boolean;
|
||||||
roles?: string;
|
command: string;
|
||||||
|
description?: string;
|
||||||
|
name: string;
|
||||||
permissions?: string;
|
permissions?: string;
|
||||||
|
roles?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const validRoles: Set<Role> = new Set(Object.values(Role));
|
const validRoles: Set<Role> = new Set(Object.values(Role));
|
||||||
@@ -42,6 +43,7 @@ const keyOptions: ArgumentConfig<KeyFlags> = {
|
|||||||
command: { type: String, description: 'get or create' },
|
command: { type: String, description: 'get or create' },
|
||||||
name: { type: String, description: 'Name of the API key', typeLabel: '{underline name}' },
|
name: { type: String, description: 'Name of the API key', typeLabel: '{underline name}' },
|
||||||
create: { type: Boolean, optional: true, description: "Create the key if it doesn't exist" },
|
create: { type: Boolean, optional: true, description: "Create the key if it doesn't exist" },
|
||||||
|
description: { type: String, optional: true, description: 'Description of the API key' },
|
||||||
roles: {
|
roles: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -70,12 +72,12 @@ export const key = async (...argv: string[]) => {
|
|||||||
const roles = validateRoles(options.roles);
|
const roles = validateRoles(options.roles);
|
||||||
const key = await apiKeyService.create(
|
const key = await apiKeyService.create(
|
||||||
options.name,
|
options.name,
|
||||||
`CLI generated key: ${options.name}`,
|
options.description || `CLI generated key: ${options.name}`,
|
||||||
roles,
|
roles,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('API Key: ', key);
|
cliLogger.info('API Key: ', key);
|
||||||
cliLogger.info('API key created successfully');
|
cliLogger.info('API key created successfully');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -88,15 +90,15 @@ export const key = async (...argv: string[]) => {
|
|||||||
const roles = validateRoles(options.roles);
|
const roles = validateRoles(options.roles);
|
||||||
const newKey = await apiKeyService.create(
|
const newKey = await apiKeyService.create(
|
||||||
options.name,
|
options.name,
|
||||||
`CLI generated key: ${options.name}`,
|
options.description || `CLI generated key: ${options.name}`,
|
||||||
roles,
|
roles,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log('New API Key: ', newKey);
|
cliLogger.info('New API Key: ', newKey);
|
||||||
cliLogger.info('API key created successfully');
|
cliLogger.info('API key created successfully');
|
||||||
} else if (key) {
|
} else if (key) {
|
||||||
console.log('API Key: ', key);
|
cliLogger.info('API Key: ', key);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`No API key found with name: ${options.name}`);
|
throw new Error(`No API key found with name: ${options.name}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user