static async Task <string> CreateAlias(string name, string fleetId) { var config = new AmazonGameLiftConfig(); config.RegionEndpoint = region; using (AmazonGameLiftClient aglc = new AmazonGameLiftClient(config)) { // create fleet var careq = new Amazon.GameLift.Model.CreateAliasRequest(); careq.Name = name; careq.Description = "Alias to direct traffic to " + fleetId; careq.RoutingStrategy = new RoutingStrategy { Type = RoutingStrategyType.SIMPLE, FleetId = fleetId, Message = "" }; Amazon.GameLift.Model.CreateAliasResponse cares = await aglc.CreateAliasAsync(careq); return(cares.Alias.AliasId); } }
private Amazon.GameLift.Model.CreateAliasResponse CallAWSServiceOperation(IAmazonGameLift client, Amazon.GameLift.Model.CreateAliasRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon GameLift Service", "CreateAlias"); try { #if DESKTOP return(client.CreateAlias(request)); #elif CORECLR return(client.CreateAliasAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.GameLift.Model.CreateAliasRequest(); if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } if (cmdletContext.Name != null) { request.Name = cmdletContext.Name; } // populate RoutingStrategy var requestRoutingStrategyIsNull = true; request.RoutingStrategy = new Amazon.GameLift.Model.RoutingStrategy(); System.String requestRoutingStrategy_routingStrategy_FleetId = null; if (cmdletContext.RoutingStrategy_FleetId != null) { requestRoutingStrategy_routingStrategy_FleetId = cmdletContext.RoutingStrategy_FleetId; } if (requestRoutingStrategy_routingStrategy_FleetId != null) { request.RoutingStrategy.FleetId = requestRoutingStrategy_routingStrategy_FleetId; requestRoutingStrategyIsNull = false; } System.String requestRoutingStrategy_routingStrategy_Message = null; if (cmdletContext.RoutingStrategy_Message != null) { requestRoutingStrategy_routingStrategy_Message = cmdletContext.RoutingStrategy_Message; } if (requestRoutingStrategy_routingStrategy_Message != null) { request.RoutingStrategy.Message = requestRoutingStrategy_routingStrategy_Message; requestRoutingStrategyIsNull = false; } Amazon.GameLift.RoutingStrategyType requestRoutingStrategy_routingStrategy_Type = null; if (cmdletContext.RoutingStrategy_Type != null) { requestRoutingStrategy_routingStrategy_Type = cmdletContext.RoutingStrategy_Type; } if (requestRoutingStrategy_routingStrategy_Type != null) { request.RoutingStrategy.Type = requestRoutingStrategy_routingStrategy_Type; requestRoutingStrategyIsNull = false; } // determine if request.RoutingStrategy should be set to null if (requestRoutingStrategyIsNull) { request.RoutingStrategy = null; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
/// <summary> /// Initiates the asynchronous execution of the CreateAlias operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateAlias operation on AmazonGameLiftClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateAlias /// operation.</returns> public IAsyncResult BeginCreateAlias(CreateAliasRequest request, AsyncCallback callback, object state) { var marshaller = new CreateAliasRequestMarshaller(); var unmarshaller = CreateAliasResponseUnmarshaller.Instance; return BeginInvoke<CreateAliasRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Creates an alias for a fleet. You can use an alias to anonymize your fleet by referencing /// an alias instead of a specific fleet when you create game sessions. Amazon GameLift /// supports two types of routing strategies for aliases: simple and terminal. Use a simple /// alias to point to an active fleet. Use a terminal alias to display a message to incoming /// traffic instead of routing players to an active fleet. This option is useful when /// a game server is no longer supported but you want to provide better messaging than /// a standard 404 error. /// /// /// <para> /// To create a fleet alias, specify an alias name, routing strategy, and optional description. /// If successful, a new alias record is returned, including an alias ID, which you can /// reference when creating a game session. To reassign the alias to another fleet ID, /// call <a>UpdateAlias</a>. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateAlias service method.</param> /// /// <returns>The response from the CreateAlias service method, as returned by GameLift.</returns> /// <exception cref="Amazon.GameLift.Model.ConflictException"> /// The requested operation would cause a conflict with the current state of a service /// resource associated with the request. Please resolve the conflict before retrying /// this request. /// </exception> /// <exception cref="Amazon.GameLift.Model.InternalServiceException"> /// The service encountered an unrecoverable internal failure while processing the request. /// Such requests can be retried by clients, either immediately or after a back-off period. /// </exception> /// <exception cref="Amazon.GameLift.Model.InvalidRequestException"> /// One or more parameters specified as part of the request are invalid. Please correct /// the invalid parameters before retrying. /// </exception> /// <exception cref="Amazon.GameLift.Model.LimitExceededException"> /// The requested operation would cause the resource to exceed the allowed service limit. /// Please resolve the issue before retrying. /// </exception> /// <exception cref="Amazon.GameLift.Model.UnauthorizedException"> /// The client failed authentication. Such requests should not be retried without valid /// authentication credentials. /// </exception> public CreateAliasResponse CreateAlias(CreateAliasRequest request) { var marshaller = new CreateAliasRequestMarshaller(); var unmarshaller = CreateAliasResponseUnmarshaller.Instance; return Invoke<CreateAliasRequest,CreateAliasResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the CreateAlias operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateAlias operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<CreateAliasResponse> CreateAliasAsync(CreateAliasRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateAliasRequestMarshaller(); var unmarshaller = CreateAliasResponseUnmarshaller.Instance; return InvokeAsync<CreateAliasRequest,CreateAliasResponse>(request, marshaller, unmarshaller, cancellationToken); }