本文整理汇总了TypeScript中typed-rest-client/RestClient.RestClient.replace方法的典型用法代码示例。如果您正苦于以下问题:TypeScript RestClient.replace方法的具体用法?TypeScript RestClient.replace怎么用?TypeScript RestClient.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typed-rest-client/RestClient.RestClient
的用法示例。
在下文中一共展示了RestClient.replace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addOrUpdateAzureMetricAlertRule
public async addOrUpdateAzureMetricAlertRule(
resourceGroupName: string,
resourceUri: string,
rule: IAzureMetricAlertRule,
notifyServiceOwners: boolean,
notifyEmails: string) : Promise<IRestResponse<any>> {
let deferred: Q.Deferred<IRestResponse<any>> = Q.defer<IRestResponse<any>>();
let requestBody: IAzureMetricAlertRequestBody = await this._getRequestBodyForAddingAlertRule(resourceGroupName, resourceUri, rule, notifyServiceOwners, notifyEmails);
tl.debug(`Sending PUT request with request body \n${JSON.stringify(requestBody, null, 2)}`);
let accessToken: string = await this._authorizationClient.getBearerToken();
let apiVersion = "2016-03-01";
let restUrl = `${this._endpoint.url}subscriptions/${this._endpoint.subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.insights/alertrules/${rule.alertName}?api-version=${apiVersion}`;
let restOptions: IRequestOptions = {
additionalHeaders: {
"Authorization": "Bearer " + accessToken
}
};
tl.debug(`Requesting : ${restUrl}`);
this._restClient.replace(restUrl, requestBody, restOptions)
.then((response: IRestResponse<any>) => {
if(response.statusCode === 200 || response.statusCode === 201) {
deferred.resolve(response);
}
else {
tl.debug(`Updating the rule ${rule.alertName} failed. Response: \n${JSON.stringify(response, null, 2)}`);
deferred.reject(response.statusCode);
}
}, (error) => {
deferred.reject(error);
}
);
return deferred.promise;
}