public Response Create(string resourceGroupName, string scriptName, DeploymentScript deploymentScript, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (scriptName == null) { throw new ArgumentNullException(nameof(scriptName)); } if (deploymentScript == null) { throw new ArgumentNullException(nameof(deploymentScript)); } using var message = CreateCreateRequest(resourceGroupName, scriptName, deploymentScript); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } }
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); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = DeploymentScript.DeserializeDeploymentScript(document.RootElement); } return(Response.FromValue(value, message.Response)); }
public static DeploymentScript GetDeploymentScript(this ArmClient client, ResourceIdentifier id) { return(client.GetClient(() => { DeploymentScript.ValidateResourceId(id); return new DeploymentScript(client, id); } )); }
public virtual DeploymentScriptsCreateOperation StartCreate(string resourceGroupName, string scriptName, DeploymentScript deploymentScript, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (scriptName == null) { throw new ArgumentNullException(nameof(scriptName)); } if (deploymentScript == null) { throw new ArgumentNullException(nameof(deploymentScript)); } using var scope = _clientDiagnostics.CreateScope("DeploymentScriptsOperations.StartCreate"); scope.Start(); try { var originalResponse = RestClient.Create(resourceGroupName, scriptName, deploymentScript, cancellationToken); return(new DeploymentScriptsCreateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateRequest(resourceGroupName, scriptName, deploymentScript).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
internal Core.HttpMessage CreateCreateRequest(string resourceGroupName, string scriptName, DeploymentScript deploymentScript) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; 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"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(deploymentScript); request.Content = content; return(message); }
public static DeploymentScript GetDeploymentScript(this ArmClient armClient, ResourceIdentifier id) { DeploymentScript.ValidateResourceId(id); return(new DeploymentScript(armClient, id)); }