本文整理匯總了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;
}