internal virtual CreateNetworkResponse CreateNetwork(CreateNetworkRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateNetworkRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateNetworkResponseUnmarshaller.Instance;

            return(Invoke <CreateNetworkResponse>(request, options));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateNetwork operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateNetwork 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>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/managedblockchain-2018-09-24/CreateNetwork">REST API Reference for CreateNetwork Operation</seealso>
        public virtual Task <CreateNetworkResponse> CreateNetworkAsync(CreateNetworkRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateNetworkRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateNetworkResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateNetworkResponse>(request, options, cancellationToken));
        }
예제 #3
0
        public async Task <IActionResult> Create([FromBody] CreateNetworkDto network)
        {
            var request  = new CreateNetworkRequest(network);
            var response = await _mediator.Send(request);

            var envelope = new Envelope <string>(response);

            return(CreatedAtAction(nameof(Retrieve), new { id = envelope.Data }, envelope));
        }
예제 #4
0
 /// <summary>
 ///     Creates a new network in corporate ethernet map for assignment of emergency addresses to network access points.
 ///     HTTP Method: post
 ///     Endpoint: /restapi/{apiVersion}/account/{accountId}/emergency-address-auto-update/networks
 ///     Rate Limit Group: Heavy
 ///     App Permission: EditAccounts
 ///     User Permission: ConfigureEmergencyMaps
 /// </summary>
 public async Task <NetworkInfo> Post(CreateNetworkRequest createNetworkRequest,
                                      RestRequestConfig restRequestConfig = null)
 {
     return(await rc.Post <NetworkInfo>(Path(false), createNetworkRequest, null, restRequestConfig));
 }
예제 #5
0
        /// <summary>
        /// Creates docker network using the cns plugin.
        /// </summary>
        /// <param name="networkName"></param>
        /// <returns></returns>
        private bool CreateNetwork(string networkName)
        {
            bool success = false;

            DeployerTrace.WriteInfo("Creating network Name:{0} using cns plugin.", networkName);

            try
            {
                string dockerNetworkId   = string.Empty;
                string dockerNetworkName = string.Empty;
                if (GetNetwork(networkName, out dockerNetworkName, out dockerNetworkId))
                {
                    if (string.IsNullOrEmpty(dockerNetworkId))
                    {
                        // Initialize network configuration
                        var initReq = new InitializeRequest
                        {
                            Location    = FlatNetworkConstants.NetworkEnvAzure,
                            NetworkType = FlatNetworkConstants.UnderlayNetworkType
                        };

                        var initRes = httpClient.PostAsync(
                            FlatNetworkConstants.NetworkEnvInitializationUrl,
                            new StringContent(JsonConvert.SerializeObject(initReq), Encoding.UTF8, "application/json")
                            ).GetAwaiter().GetResult();

                        string response = initRes.Content.ReadAsStringAsync().GetAwaiter().GetResult();

                        if (!initRes.IsSuccessStatusCode)
                        {
                            DeployerTrace.WriteError("Failed to initialize network environment Name:{0} error details {1}.", networkName, response);
                        }
                        else
                        {
                            var initResult = JsonConvert.DeserializeObject <CnsResponse>(response);
                            if (initResult.ReturnCode != 0)
                            {
                                DeployerTrace.WriteWarning(
                                    "Network Name:{0} environment initialize returned error code {1}, message {2}",
                                    networkName,
                                    initResult.ReturnCode,
                                    initResult.Message);
                                return(success);
                            }

                            // Create network
                            var createNetworkReq = new CreateNetworkRequest
                            {
                                NetworkName = networkName
                            };

                            var createNetworkRes = httpClient.PostAsync(
                                FlatNetworkConstants.NetworkCreateUrl,
                                new StringContent(JsonConvert.SerializeObject(createNetworkReq), Encoding.UTF8, "application/json")
                                ).GetAwaiter().GetResult();

                            response = createNetworkRes.Content.ReadAsStringAsync().GetAwaiter().GetResult();

                            if (!createNetworkRes.IsSuccessStatusCode)
                            {
                                DeployerTrace.WriteError("Failed to create network Name:{0} error details {1}.", networkName, response);
                            }
                            else
                            {
                                var createNetworkResult = JsonConvert.DeserializeObject <CnsResponse>(response);
                                if (createNetworkResult.ReturnCode != 0)
                                {
                                    DeployerTrace.WriteWarning(
                                        "Network Name:{0} network create returned error code {1}, message {2}",
                                        networkName,
                                        createNetworkResult.ReturnCode,
                                        createNetworkResult.Message);
                                    return(success);
                                }

                                success = true;
                                DeployerTrace.WriteInfo("Network Name:{0} created successfully.", networkName);
                            }
                        }
                    }
                    else
                    {
                        success = true;
                        DeployerTrace.WriteInfo("Skipping network creation since network {0} already exists.", networkName);
                    }
                }
            }
            catch (Exception ex)
            {
                DeployerTrace.WriteError("Failed to create network Name:{0} exception {1}.", networkName, ex);
            }

            return(success);
        }