|
| 1 | +{ |
| 2 | + "xMatters Endpoint Index": { |
| 3 | + "prefix": "xm-endpoint", |
| 4 | + "description": "Generate a complete endpoint index.ts file", |
| 5 | + "body": [ |
| 6 | + "import { ResourceClient } from 'core/resource-client.ts';", |
| 7 | + "import type {", |
| 8 | + " Create${1:Resource},", |
| 9 | + " Get${1:Resource}Params,", |
| 10 | + " Get${1:Resource}sParams,", |
| 11 | + " ${1:Resource},", |
| 12 | + " Update${1:Resource},", |
| 13 | + "} from './types.ts';", |
| 14 | + "import type { HttpResponse, PaginatedHttpResponse, PaginatedResponse } from 'types/http.ts';", |
| 15 | + "import type { Options } from 'types/request-building-options.ts';", |
| 16 | + "import type { RequestHandler } from 'core/request-handler.ts';", |
| 17 | + "", |
| 18 | + "/**", |
| 19 | + " * Provides access to the ${2:${1/(.*)/${1:/downcase}/}}s endpoints of the xMatters API.", |
| 20 | + " * Use this class to manage ${2:${1/(.*)/${1:/downcase}/}}s, including listing, creating, updating, and deleting ${2:${1/(.*)/${1:/downcase}/}}s.", |
| 21 | + " */", |
| 22 | + "export class ${1:Resource}sEndpoint {", |
| 23 | + " private readonly http: ResourceClient;", |
| 24 | + "", |
| 25 | + " constructor(http: RequestHandler) {", |
| 26 | + " this.http = new ResourceClient(http, '/${3:${1/(.*)/${1:/downcase}/}}s');", |
| 27 | + " }", |
| 28 | + "", |
| 29 | + " /**", |
| 30 | + " * Get a list of ${2:${1/(.*)/${1:/downcase}/}}s from xMatters.", |
| 31 | + " * The results can be filtered and paginated using the options object.", |
| 32 | + " *", |
| 33 | + " * @param options Optional parameters including query filters, headers, and other request options", |
| 34 | + " * @returns The HTTP response containing a paginated list of ${2:${1/(.*)/${1:/downcase}/}}s", |
| 35 | + " * @throws {XmApiError} If the request fails", |
| 36 | + " */", |
| 37 | + " get(", |
| 38 | + " options?: Options & { query?: Get${1:Resource}sParams },", |
| 39 | + " ): Promise<PaginatedHttpResponse<${1:Resource}>> {", |
| 40 | + " return this.http.get<PaginatedResponse<${1:Resource}>>(options);", |
| 41 | + " }", |
| 42 | + "", |
| 43 | + " /**", |
| 44 | + " * Get a ${2:${1/(.*)/${1:/downcase}/}} by its ID or targetName.", |
| 45 | + " *", |
| 46 | + " * @param identifier The ID or targetName of the ${2:${1/(.*)/${1:/downcase}/}} to retrieve", |
| 47 | + " * @param options Optional request options including embed parameters and headers", |
| 48 | + " * @returns The HTTP response containing the ${2:${1/(.*)/${1:/downcase}/}}", |
| 49 | + " * @throws {XmApiError} If the request fails", |
| 50 | + " */", |
| 51 | + " getByIdentifier(", |
| 52 | + " identifier: string,", |
| 53 | + " options?: Options & { query?: Get${1:Resource}Params },", |
| 54 | + " ): Promise<HttpResponse<${1:Resource}>> {", |
| 55 | + " return this.http.get<${1:Resource}>({ ...options, path: identifier });", |
| 56 | + " }", |
| 57 | + "", |
| 58 | + " /**", |
| 59 | + " * Create a new ${2:${1/(.*)/${1:/downcase}/}} or update an existing one", |
| 60 | + " *", |
| 61 | + " * @param ${2:${1/(.*)/${1:/downcase}/}} The ${2:${1/(.*)/${1:/downcase}/}} to create or update", |
| 62 | + " * @param options Optional request options such as custom headers", |
| 63 | + " * @returns The HTTP response containing the created or updated ${2:${1/(.*)/${1:/downcase}/}}", |
| 64 | + " * @throws {XmApiError} If the request fails", |
| 65 | + " */", |
| 66 | + " save(", |
| 67 | + " ${2:${1/(.*)/${1:/downcase}/}}: Create${1:Resource} | Update${1:Resource},", |
| 68 | + " options?: Options,", |
| 69 | + " ): Promise<HttpResponse<${1:Resource}>> {", |
| 70 | + " return this.http.post<${1:Resource}>({ ...options, body: ${2:${1/(.*)/${1:/downcase}/}} });", |
| 71 | + " }", |
| 72 | + "", |
| 73 | + " /**", |
| 74 | + " * Delete a ${2:${1/(.*)/${1:/downcase}/}} by ID", |
| 75 | + " *", |
| 76 | + " * @param id The ID of the ${2:${1/(.*)/${1:/downcase}/}} to delete", |
| 77 | + " * @param options Optional request options such as custom headers", |
| 78 | + " * @returns The HTTP response", |
| 79 | + " * @throws {XmApiError} If the request fails", |
| 80 | + " */", |
| 81 | + " delete(id: string, options?: Options): Promise<HttpResponse<${1:Resource}>> {", |
| 82 | + " return this.http.delete<${1:Resource}>({ ...options, path: id });", |
| 83 | + " }", |
| 84 | + "}", |
| 85 | + "$0" |
| 86 | + ] |
| 87 | + } |
| 88 | +} |
0 commit comments