當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript RestClient.replace方法代碼示例

本文整理匯總了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;
	}
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:40,代碼來源:azurermalertrulesrestclient.ts


注:本文中的typed-rest-client/RestClient.RestClient.replace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。