Beispiel #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateConnectionRequest request;

            try
            {
                request = new UpdateConnectionRequest
                {
                    CatalogId               = CatalogId,
                    DataAssetKey            = DataAssetKey,
                    ConnectionKey           = ConnectionKey,
                    UpdateConnectionDetails = UpdateConnectionDetails,
                    IfMatch      = IfMatch,
                    OpcRequestId = OpcRequestId
                };

                response = client.UpdateConnection(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Connection);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Beispiel #2
0
 /// <summary>Snippet for UpdateConnection</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void UpdateConnectionRequestObject()
 {
     // Create client
     ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.Create();
     // Initialize request argument(s)
     UpdateConnectionRequest request = new UpdateConnectionRequest
     {
         ConnectionName = ConnectionName.FromProjectLocationConnection("[PROJECT]", "[LOCATION]", "[CONNECTION]"),
         Connection     = new Connection(),
         UpdateMask     = new FieldMask(),
     };
     // Make the request
     Connection response = connectionServiceClient.UpdateConnection(request);
 }
        /// <summary>
        /// 更新事件连接器
        /// </summary>
        /// <param name="req"><see cref="UpdateConnectionRequest"/></param>
        /// <returns><see cref="UpdateConnectionResponse"/></returns>
        public UpdateConnectionResponse UpdateConnectionSync(UpdateConnectionRequest req)
        {
            JsonResponseModel <UpdateConnectionResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "UpdateConnection");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <UpdateConnectionResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
        protected override async Task <Entity> UpdateAsync(IDictionary <string, object> propertyUpdates, IDictionary <string, string> attributeUpdates, IEnumerable <string> addedTags, IEnumerable <string> removedTags, int specificRevision, ApiOptions options, bool forceUpdate)
        {
            var request = new UpdateConnectionRequest {
                Id = this.Id, Type = this.Type, Revision = specificRevision
            };

            ApiOptions.Apply(request, options);
            request.Revision = specificRevision;
            if (propertyUpdates != null && propertyUpdates.Count > 0)
            {
                propertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value);
            }
            if (attributeUpdates != null && attributeUpdates.Count > 0)
            {
                attributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value);
            }
            if (addedTags != null)
            {
                request.AddedTags.AddRange(addedTags);
            }
            if (removedTags != null)
            {
                request.RemovedTags.AddRange(removedTags);
            }

            // Check if an update is needed.
            if (request.PropertyUpdates.Count == 0 &&
                request.AttributeUpdates.Count == 0 &&
                request.AddedTags.Count == 0 &&
                request.RemovedTags.Count == 0 &&
                forceUpdate == false)
            {
                return(null);
            }

            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }

            // 3. Update the last known state based on the differences
            Debug.Assert(response.Connection != null, "If status is successful, then updated connection should not be null.");
            return(response.Connection);
        }
Beispiel #5
0
        /// <summary>Snippet for UpdateConnectionAsync</summary>
        public async Task UpdateConnectionRequestObjectAsync()
        {
            // Snippet: UpdateConnectionAsync(UpdateConnectionRequest, CallSettings)
            // Additional: UpdateConnectionAsync(UpdateConnectionRequest, CancellationToken)
            // Create client
            ConnectionServiceClient connectionServiceClient = await ConnectionServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateConnectionRequest request = new UpdateConnectionRequest
            {
                ConnectionName = ConnectionName.FromProjectLocationConnection("[PROJECT]", "[LOCATION]", "[CONNECTION]"),
                Connection     = new Connection(),
                UpdateMask     = new FieldMask(),
            };
            // Make the request
            Connection response = await connectionServiceClient.UpdateConnectionAsync(request);

            // End snippet
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateConnectionRequest request;

            try
            {
                request = new UpdateConnectionRequest
                {
                    ConnectionId            = ConnectionId,
                    UpdateConnectionDetails = UpdateConnectionDetails,
                    OpcRequestId            = OpcRequestId,
                    IfMatch = IfMatch
                };

                response = client.UpdateConnection(request).GetAwaiter().GetResult();
                WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId));
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        protected override async Task<Entity> UpdateAsync(IDictionary<string, object> propertyUpdates, IDictionary<string, string> attributeUpdates, IEnumerable<string> addedTags, IEnumerable<string> removedTags, int specificRevision, ApiOptions options, bool forceUpdate)
        {
            var request = new UpdateConnectionRequest{ Id = this.Id, Type = this.Type, Revision = specificRevision };
            ApiOptions.Apply(request, options);
            request.Revision = specificRevision;
            if (propertyUpdates != null && propertyUpdates.Count > 0)
                propertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value);
            if (attributeUpdates != null && attributeUpdates.Count > 0)
                attributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value);
            if (addedTags != null)
                request.AddedTags.AddRange(addedTags);
            if (removedTags != null)
                request.RemovedTags.AddRange(removedTags);

            // Check if an update is needed.
            if (request.PropertyUpdates.Count == 0 &&
                request.AttributeUpdates.Count == 0 &&
                request.AddedTags.Count == 0         &&
                request.RemovedTags.Count == 0  &&
                forceUpdate == false )
                return null;

            var response = await request.ExecuteAsync();
            if (response.Status.IsSuccessful == false)
                throw response.Status.ToFault();

            // 3. Update the last known state based on the differences
            Debug.Assert(response.Connection != null, "If status is successful, then updated connection should not be null.");
            return response.Connection;
        }
        private UpdateConnectionRequest CreateUpdateRequest(EntityChanges changes, int specificRevision, ApiOptions options)
        {
            var request = new UpdateConnectionRequest { Id = this.Id, Type = this.Type, Revision = specificRevision };
            ApiOptions.Apply(request, options);
            request.Revision = specificRevision;
            if (changes.PropertyUpdates != null && changes.PropertyUpdates.Count > 0)
                changes.PropertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value);
            if (changes.AttributeUpdates != null && changes.AttributeUpdates.Count > 0)
                changes.AttributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value);
            if (changes.AddedTags != null)
                request.AddedTags.AddRange(changes.AddedTags);
            if (changes.RemovedTags != null)
                request.RemovedTags.AddRange(changes.RemovedTags);

            return request;
        }