当前位置: 首页>>代码示例>>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;未经允许,请勿转载。