Esempio n. 1
0
        public async Task CreateConnectionTest()
        {
            var obj1 = await ObjectHelper.CreateNewAsync();

            var obj2 = await ObjectHelper.CreateNewAsync();

            dynamic conn = new Connection("sibling", "object", obj1.Id, "object", obj2.Id);

            conn.field1 = Unique.String;
            conn.field2 = 123;

            var request = new CreateConnectionRequest()
            {
                Connection = conn
            };
            var response = await request.ExecuteAsync();

            ApiHelper.EnsureValidResponse(response);
            Assert.IsNotNull(response.Connection, "Connection in create connection response is null.");
            Assert.IsFalse(string.IsNullOrWhiteSpace(response.Connection.Id), "Connection id in response.connection is invalid.");
            var endpoints = response.Connection.Endpoints.ToArray();

            Assert.IsNotNull(endpoints[0], "Endpoint A is null.");
            Assert.IsNotNull(endpoints[1], "Endpoint B is null.");
            Assert.IsTrue(endpoints.Select(x => x.ArticleId).Intersect(new[] { obj1.Id, obj2.Id }).Count() == 2);
        }
        public bool Validate(CreateConnectionRequest requestToValidate)

        {
            return(!((requestToValidate.UserId1 == null) ||
                     (requestToValidate.UserId2 == null) ||
                     (requestToValidate.IsFriend == null)));
        }
        /// <summary>
        /// <para>Creates a new connection between the customer network and a specific AWS Direct Connect location.</para> <para>A connection links your
        /// internal network to an AWS Direct Connect location over a standard 1 gigabit or 10 gigabit Ethernet fiber-optic cable. One end of the cable
        /// is connected to your router, the other to an AWS Direct Connect router. A Direct Connect location provides access to Amazon Web Services in
        /// the region it is associated with. You can establish connections with AWS Direct Connect locations in multiple regions, but a connection in
        /// one region does not provide connectivity to other regions.</para>
        /// </summary>
        ///
        /// <param name="createConnectionRequest">Container for the necessary parameters to execute the CreateConnection service method on
        /// AmazonDirectConnect.</param>
        ///
        /// <returns>The response from the CreateConnection service method, as returned by AmazonDirectConnect.</returns>
        ///
        /// <exception cref="T:Amazon.DirectConnect.Model.DirectConnectServerException" />
        /// <exception cref="T:Amazon.DirectConnect.Model.DirectConnectClientException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        public Task <CreateConnectionResponse> CreateConnectionAsync(CreateConnectionRequest createConnectionRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreateConnectionRequestMarshaller();
            var unmarshaller = CreateConnectionResponseUnmarshaller.GetInstance();

            return(Invoke <IRequest, CreateConnectionRequest, CreateConnectionResponse>(createConnectionRequest, marshaller, unmarshaller, signer, cancellationToken));
        }
Esempio n. 4
0
        internal CreateConnectionResponse CreateConnection(CreateConnectionRequest request)
        {
            var marshaller   = new CreateConnectionRequestMarshaller();
            var unmarshaller = CreateConnectionResponseUnmarshaller.Instance;

            return(Invoke <CreateConnectionRequest, CreateConnectionResponse>(request, marshaller, unmarshaller));
        }
Esempio n. 5
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            CreateConnectionRequest request;

            try
            {
                request = new CreateConnectionRequest
                {
                    CatalogId               = CatalogId,
                    DataAssetKey            = DataAssetKey,
                    CreateConnectionDetails = CreateConnectionDetails,
                    OpcRequestId            = OpcRequestId,
                    OpcRetryToken           = OpcRetryToken
                };

                response = client.CreateConnection(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Connection);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        /// <summary>
        /// Creates a connection that can then be given to other AWS services like CodePipeline
        /// so that it can access third-party code repositories. The connection is in pending
        /// status until the third-party connection handshake is completed from the console.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the CreateConnection service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// 
        /// <returns>The response from the CreateConnection service method, as returned by CodeStarconnections.</returns>
        /// <exception cref="Amazon.CodeStarconnections.Model.LimitExceededException">
        /// Exceeded the maximum limit for connections.
        /// </exception>
        /// <exception cref="Amazon.CodeStarconnections.Model.ResourceNotFoundException">
        /// Resource not found. Verify the connection resource ARN and try again.
        /// </exception>
        /// <exception cref="Amazon.CodeStarconnections.Model.ResourceUnavailableException">
        /// Resource not found. Verify the ARN for the host resource and try again.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codestar-connections-2019-12-01/CreateConnection">REST API Reference for CreateConnection Operation</seealso>
        public virtual Task<CreateConnectionResponse> CreateConnectionAsync(CreateConnectionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = CreateConnectionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateConnectionResponseUnmarshaller.Instance;

            return InvokeAsync<CreateConnectionResponse>(request, options, cancellationToken);
        }
        internal virtual CreateConnectionResponse CreateConnection(CreateConnectionRequest request)
        {
            var options = new InvokeOptions();
            options.RequestMarshaller = CreateConnectionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateConnectionResponseUnmarshaller.Instance;

            return Invoke<CreateConnectionResponse>(request, options);
        }
Esempio n. 8
0
        /// <summary>
        /// Initiates the asynchronous execution of the CreateConnection operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateConnection 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 <CreateConnectionResponse> CreateConnectionAsync(CreateConnectionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreateConnectionRequestMarshaller();
            var unmarshaller = CreateConnectionResponseUnmarshaller.Instance;

            return(InvokeAsync <CreateConnectionRequest, CreateConnectionResponse>(request, marshaller,
                                                                                   unmarshaller, cancellationToken));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateConnection operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreateConnection operation on AmazonCodeStarconnectionsClient.</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 EndCreateConnection
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codestar-connections-2019-12-01/CreateConnection">REST API Reference for CreateConnection Operation</seealso>
        public virtual IAsyncResult BeginCreateConnection(CreateConnectionRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = CreateConnectionRequestMarshaller.Instance;
            options.ResponseUnmarshaller = CreateConnectionResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Esempio n. 10
0
        public ActionResult AddConnection(CreateConnectionRequest createRequest)
        {
            if (!_validator.Validate(createRequest))
            {
                return(BadRequest(new { error = "conections must have a userId1, userId2 and a 'isFriend' bool." }));
            }

            var newConnection = _connectionRepository.AddConnection(createRequest.UserId1, createRequest.UserId2, createRequest.IsFriend);

            return(Created($"api/connect/{newConnection.Id}", newConnection));
        }
Esempio n. 11
0
        public IActionResult CreateConnection([FromBody] CreateConnectionRequest request)
        {
            var client    = new MySqlConnection($"Server={request.Address}; Port={request.Port}; Uid={request.Username}; Pwd={request.Password}; Pooling=False");
            var timestamp = DateTime.UtcNow.Ticks.ToString();

            ConnectionHelper.Connections.Add(timestamp, client);
            return(Json(new CreateConnectionResponse
            {
                Id = timestamp
            }));
        }
Esempio n. 12
0
 /// <summary>Snippet for CreateConnection</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreateConnectionRequestObject()
 {
     // Create client
     ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.Create();
     // Initialize request argument(s)
     CreateConnectionRequest request = new CreateConnectionRequest
     {
         ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
         ConnectionId         = "",
         Connection           = new Connection(),
     };
     // Make the request
     Connection response = connectionServiceClient.CreateConnection(request);
 }
        internal CreateConnectionResponse CreateConnection(CreateConnectionRequest request)
        {
            var task = CreateConnectionAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
        /// <summary>
        /// 创建事件连接器
        /// </summary>
        /// <param name="req"><see cref="CreateConnectionRequest"/></param>
        /// <returns><see cref="CreateConnectionResponse"/></returns>
        public CreateConnectionResponse CreateConnectionSync(CreateConnectionRequest req)
        {
            JsonResponseModel <CreateConnectionResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "CreateConnection");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <CreateConnectionResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Esempio n. 15
0
 public IActionResult CreateConnection([FromBody] CreateConnectionRequest request)
 {
     if (!ConnectionHelper.Connections.ContainsKey(request.InstanceId))
     {
         var client = new MySqlConnection($"Server={request.Address}; Port={request.Port}; Uid={request.Username}; Pwd={request.Password}; Pooling=False; AllowUserVariables=True; Keepalive=60;");
         if (string.IsNullOrEmpty(request.InstanceId))
         {
             request.InstanceId = DateTime.UtcNow.Ticks.ToString();
         }
         ConnectionHelper.Connections.Add(request.InstanceId, client);
     }
     return(Json(new CreateConnectionResponse
     {
         Id = request.InstanceId
     }));
 }
Esempio n. 16
0
        public async Task CreateConnectionWithNewArticlesAsyncTest()
        {
            var     obj1 = ObjectHelper.NewInstance();
            var     obj2 = ObjectHelper.NewInstance();
            dynamic conn = new Connection("sibling", "object", obj1, "object", obj2);

            conn.field1 = Unique.String;
            conn.field2 = 123;

            var request = new CreateConnectionRequest()
            {
                Connection = conn
            };
            var response = await request.ExecuteAsync();

            ApiHelper.EnsureValidResponse(response);
            Assert.IsNotNull(response.Connection, "Connection in create connection response is null.");
            Assert.IsFalse(string.IsNullOrWhiteSpace(response.Connection.Id), "Connection id in response.connection is invalid.");
        }
Esempio n. 17
0
        /// <summary>Snippet for CreateConnectionAsync</summary>
        public async Task CreateConnectionRequestObjectAsync()
        {
            // Snippet: CreateConnectionAsync(CreateConnectionRequest, CallSettings)
            // Additional: CreateConnectionAsync(CreateConnectionRequest, CancellationToken)
            // Create client
            ConnectionServiceClient connectionServiceClient = await ConnectionServiceClient.CreateAsync();

            // Initialize request argument(s)
            CreateConnectionRequest request = new CreateConnectionRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                ConnectionId         = "",
                Connection           = new Connection(),
            };
            // Make the request
            Connection response = await connectionServiceClient.CreateConnectionAsync(request);

            // End snippet
        }
Esempio n. 18
0
 public async Task <IActionResult> TestConnection([FromBody] CreateConnectionRequest request)
 {
     using (var client = new MySqlConnection($"Server={request.Address}; Port={request.Port}; Uid={request.Username}; Pwd={request.Password}; Pooling=False"))
     {
         try
         {
             await client.OpenAsync();
         }
         catch (MySqlException ex)
         {
             Response.StatusCode = 400;
             return(Json(new DBError
             {
                 Code = ex.Number,
                 Message = ex.Message
             }));
         }
         return(Json("OK"));
     }
 }
Esempio n. 19
0
        protected async override Task <Entity> CreateNewAsync(ApiOptions options)
        {
            // Handling for special case when endpoint contains a new object or device.
            // Since these cannot be created on the fly when creating a new connection.
            var endpoints = this.Endpoints.ToArray();

            for (int i = 0; i < endpoints.Length; i++)
            {
                if (endpoints[i].CreateEndpoint == false)
                {
                    continue;
                }
                if (endpoints[i].Content.Type.Equals("user", StringComparison.OrdinalIgnoreCase) == true ||
                    endpoints[i].Content.Type.Equals("device", StringComparison.OrdinalIgnoreCase) == true)
                {
                    // Create the object
                    await endpoints[i].Content.SaveAsync(options: options);
                    // Update endpoint object ids
                    endpoints[i].ObjectId = endpoints[i].Content.Id;
                }
            }

            // Create a new object
            var request = new CreateConnectionRequest()
            {
                Connection = this
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            Debug.Assert(response.Connection != null, "If status is successful, then created connection should not be null.");
            return(response.Connection);
        }