2019-06-23 03:35:23 -07:00
|
|
|
import {
|
2022-05-27 08:15:12 -07:00
|
|
|
ICredentialDataDecryptedObject,
|
|
|
|
ICredentialTestRequest,
|
2019-06-23 03:35:23 -07:00
|
|
|
ICredentialType,
|
2022-05-27 08:15:12 -07:00
|
|
|
IHttpRequestOptions,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2019-06-23 03:35:23 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class NextCloudApi implements ICredentialType {
|
|
|
|
name = 'nextCloudApi';
|
|
|
|
displayName = 'NextCloud API';
|
2020-08-17 05:42:09 -07:00
|
|
|
documentationUrl = 'nextCloud';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2019-06-23 03:35:23 -07:00
|
|
|
{
|
|
|
|
displayName: 'Web DAV URL',
|
|
|
|
name: 'webDavUrl',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-07-22 14:52:40 -07:00
|
|
|
placeholder: 'https://nextcloud.example.com/remote.php/webdav',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'User',
|
|
|
|
name: 'user',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Password',
|
|
|
|
name: 'password',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-05-27 08:15:12 -07:00
|
|
|
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
|
|
|
requestOptions.auth = {
|
|
|
|
username: credentials.user as string,
|
|
|
|
password: credentials.password as string,
|
|
|
|
};
|
|
|
|
return requestOptions;
|
|
|
|
}
|
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials.webDavUrl.replace(\'/remote.php/webdav\', \'\')}}',
|
|
|
|
url: '/ocs/v1.php/cloud/capabilities',
|
|
|
|
headers: {'OCS-APIRequest': true},
|
|
|
|
},
|
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|