Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async listResources(
name: string,
listRequestOptions: ListRequestOptions | undefined,
serializer: AtomXmlSerializer
): Promise {
const queryParams: { [key: string]: string } = {};
if (listRequestOptions) {
if (listRequestOptions.skip) {
queryParams["$skip"] = listRequestOptions.skip.toString();
}
if (listRequestOptions.top) {
queryParams["$top"] = listRequestOptions.top.toString();
}
}
const webResource: WebResource = new WebResource(this.getUrl(name, queryParams), "GET");
return executeAtomXmlOperation(this, webResource, serializer);
}
private async getResource(
name: string,
serializer: AtomXmlSerializer
): Promise {
const webResource: WebResource = new WebResource(this.getUrl(name), "GET");
const response = await executeAtomXmlOperation(this, webResource, serializer);
if (
response.parsedBody == undefined ||
(Array.isArray(response.parsedBody) && response.parsedBody.length == 0)
) {
const err = new RestError(
`The messaging entity "${name}" being requested cannot be found.`,
"404",
404,
stripRequest(webResource),
stripResponse(response)
);
throw err;
}
return response;
createWebResource(requestOptions: RequestPrepareOptions): WebResource {
const webResource = new WebResource();
webResource.prepare(requestOptions);
return webResource;
}
private async putResource(
name: string,
entityFields:
| InternalQueueOptions
| InternalTopicOptions
| InternalSubscriptionOptions
| InternalRuleOptions,
serializer: AtomXmlSerializer,
isUpdate: boolean = false
): Promise {
const webResource: WebResource = new WebResource(this.getUrl(name), "PUT");
webResource.body = entityFields;
if (isUpdate) {
webResource.headers.set("If-Match", "*");
}
webResource.headers.set("content-type", "application/atom+xml;type=entry;charset=utf-8");
return executeAtomXmlOperation(this, webResource, serializer);
}