/// <summary> /// Updates the deployment with the given identifier. /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> public async Task <UpdateDeploymentResponse> UpdateDeployment(UpdateDeploymentRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called updateDeployment"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/deployments/{deploymentId}".Trim('/'))); HttpMethod method = new HttpMethod("Put"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken); } else { responseMessage = await this.restClient.HttpSend(requestMessage); } return(Converter.FromHttpResponseMessage <UpdateDeploymentResponse>(responseMessage)); } catch (Exception e) { logger.Error($"UpdateDeployment failed with error: {e.Message}"); throw; } }
/// <summary> /// /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// The RPC response. /// </returns> public override UpdateDeploymentResponse UpdateDeployment( UpdateDeploymentRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_UpdateDeploymentRequest(ref request, ref callSettings); return(_callUpdateDeployment.Sync(request, callSettings)); }
public async Task <IActionResult> Update([FromRoute] string id, [FromBody] UpdateDeploymentDto deployment) { var request = new UpdateDeploymentRequest(id, deployment); await _mediator.Send(request); return(NoContent()); }
private void MarkDeploymentAsInUse(DeploymentServiceClient dplClient, Deployment dpl) { dpl.Tag.Remove(ReadyTag); dpl.Tag.Add(InUseTag); var req = new UpdateDeploymentRequest { Deployment = dpl }; dplClient.UpdateDeployment(req); }
public static void UpdateDeployment(Deployment deployment) { ExceptionHandler.HandleGrpcCall(() => { var request = new UpdateDeploymentRequest { Deployment = deployment }; deploymentServiceClient.UpdateDeployment(request); }); }
public static async Task Main(string[] args) { if (args.Length != 3) { throw new ArgumentException("Expected usage: SpotShim.exe <deployment_id> <deployment_name> <project_name>"); } var localApiEndpoint = new PlatformApiEndpoint("localhost", SpatialdPort, insecure: true); var deploymentServiceClient = DeploymentServiceClient.Create(localApiEndpoint); var request = new UpdateDeploymentRequest { Deployment = new Deployment { Id = args[0], Name = args[1], ProjectName = args[2], Tag = { "dev_login" } } }; await deploymentServiceClient.UpdateDeploymentAsync(request); }
protected override void ProcessRecord() { base.ProcessRecord(); UpdateDeploymentRequest request; try { request = new UpdateDeploymentRequest { DeploymentId = DeploymentId, UpdateDeploymentDetails = UpdateDeploymentDetails, IfMatch = IfMatch, OpcRequestId = OpcRequestId }; response = client.UpdateDeployment(request).GetAwaiter().GetResult(); WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId)); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
protected override void DoMatch(GatewayInternalService.GatewayInternalServiceClient gatewayClient, DeploymentServiceClient deploymentServiceClient) { try { var resp = gatewayClient.PopWaitingParties(new PopWaitingPartiesRequest { Type = _tag, NumParties = 1 }); Console.WriteLine($"Fetched {resp.Parties.Count} from gateway"); foreach (var party in resp.Parties) { Console.WriteLine($"Attempting to match a retrieved party of {party.Party.MemberIds.Count} players."); bool requeue = false; var deployment = GetDeploymentWithTag(deploymentServiceClient, _tag); if (deployment != null) { var assignRequest = new AssignDeploymentsRequest(); Console.WriteLine("Found a deployment."); int numPlayers = 0; foreach (string tag in deployment.Tag) { if (tag.StartsWith(PlayersTag)) { int.TryParse(tag.Split("_")[1], out numPlayers); Console.WriteLine($"Deployment already has {numPlayers} in."); break; } } int totalPlayers = numPlayers + party.Party.MemberIds.Count; if (totalPlayers <= PlayersPerDeployment) { if (numPlayers > 0) { Console.WriteLine($"Removing tag {PlayersTag}_{numPlayers}"); deployment.Tag.Remove($"{PlayersTag}_{numPlayers}"); } if (totalPlayers == PlayersPerDeployment) { Console.WriteLine("Deployment is full, marking as in_use"); MarkDeploymentAsInUse(deploymentServiceClient, deployment); } else { Console.WriteLine($"Deployment isn't full, adding tag {PlayersTag}_{totalPlayers}"); deployment.Tag.Add($"{PlayersTag}_{totalPlayers}"); var req = new UpdateDeploymentRequest { Deployment = deployment }; deploymentServiceClient.UpdateDeployment(req); } assignRequest.Assignments.Add(new Assignment { DeploymentId = deployment.Id, DeploymentName = deployment.Name, Result = Assignment.Types.Result.Matched, Party = party.Party }); gatewayClient.AssignDeployments(assignRequest); } else { Console.WriteLine("Deployment does not have space for a party of this size."); requeue = true; } } else { Console.WriteLine($"Unable to find a deployment with tag {_tag} in project {_project}"); requeue = true; } if (requeue) { Console.WriteLine("Requeueing the party"); AssignPartyAsRequeued(gatewayClient, party); } } } catch (RpcException e) { if (e.StatusCode != StatusCode.ResourceExhausted && e.StatusCode != StatusCode.Unavailable) { throw; } /* Unable to get the requested number of parties - ignore. */ Thread.Sleep(TickMs); } }
partial void Modify_UpdateDeploymentRequest(ref UpdateDeploymentRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// The RPC response. /// </returns> public virtual UpdateDeploymentResponse UpdateDeployment( UpdateDeploymentRequest request, gaxgrpc::CallSettings callSettings = null) { throw new sys::NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="cancellationToken"> /// A <see cref="st::CancellationToken"/> to use for this RPC. /// </param> /// <returns> /// A Task containing the RPC response. /// </returns> public virtual stt::Task <UpdateDeploymentResponse> UpdateDeploymentAsync( UpdateDeploymentRequest request, st::CancellationToken cancellationToken) => UpdateDeploymentAsync( request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));