internal Azure.Core.HttpMessage CreateUpdateRequest(string resourceGroupName, string scriptName, IDictionary <string, string> tags) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourcegroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Resources/deploymentScripts/", false); uri.AppendPath(scriptName, true); uri.AppendQuery("api-version", "2020-10-01", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); DeploymentScriptUpdateParameter deploymentScriptUpdateParameter = new DeploymentScriptUpdateParameter(); if (tags != null) { foreach (var value in tags) { deploymentScriptUpdateParameter.Tags.Add(value); } } var model = deploymentScriptUpdateParameter; var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(model); request.Content = content; message.SetProperty("UserAgentOverride", _userAgent); return(message); }
public virtual Response <DeploymentScript> Update(string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("DeploymentScriptsOperations.Update"); scope.Start(); try { return(RestClient.Update(resourceGroupName, scriptName, deploymentScript, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response <DeploymentScript> > UpdateAsync(string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = null, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (scriptName == null) { throw new ArgumentNullException(nameof(scriptName)); } using var message = CreateUpdateRequest(resourceGroupName, scriptName, deploymentScript); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { DeploymentScript value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = DeploymentScript.DeserializeDeploymentScript(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal Core.HttpMessage CreateUpdateRequest(string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourcegroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Resources/deploymentScripts/", false); uri.AppendPath(scriptName, true); uri.AppendQuery("api-version", "2019-10-01-preview", true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); request.Headers.Add("Accept", "application/json"); if (deploymentScript != null) { var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(deploymentScript); request.Content = content; } return(message); }
/// <summary> /// Updates deployment script tags with specified values. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='scriptName'> /// Name of the deployment script. /// </param> /// <param name='deploymentScript'> /// Deployment script resource with the tags to be updated. /// </param> public static DeploymentScript Update(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = default(DeploymentScriptUpdateParameter)) { return(operations.UpdateAsync(resourceGroupName, scriptName, deploymentScript).GetAwaiter().GetResult()); }
/// <summary> /// Updates deployment script tags with specified values. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='scriptName'> /// Name of the deployment script. /// </param> /// <param name='deploymentScript'> /// Deployment script resource with the tags to be updated. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DeploymentScript> UpdateAsync(this IDeploymentScriptsOperations operations, string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = default(DeploymentScriptUpdateParameter), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, scriptName, deploymentScript, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public virtual async Task <Response <DeploymentScript> > UpdateAsync(string resourceGroupName, string scriptName, DeploymentScriptUpdateParameter deploymentScript = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("DeploymentScriptsClient.Update"); scope.Start(); try { return(await RestClient.UpdateAsync(resourceGroupName, scriptName, deploymentScript, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }