示例#1
0
        /// <summary>
        /// Update a unit.
        /// </summary>
        /// <remarks>
        ///
        /// </remarks>
        /// <exception cref="OSIsoft.PIDevClub.PIWebApiClient.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="webId">The ID of the unit.</param>
        /// <param name="unitDTO">A partial unit containing the desired changes.</param>
        /// <returns>ApiResponse<Object></returns>
        public ApiResponse <Object> UpdateWithHttpInfo(string webId, PIUnit unitDTO)
        {
            // verify the required parameter 'webId' is set
            if (webId == null)
            {
                throw new ApiException(400, "Missing required parameter 'webId'");
            }
            // verify the required parameter 'unitDTO' is set
            if (unitDTO == null)
            {
                throw new ApiException(400, "Missing required parameter 'unitDTO'");
            }

            var    localVarPath         = "/units/{webId}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new CustomDictionaryForQueryString();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            string localVarPostBody     = null;

            if (webId != null)
            {
                localVarPathParams.Add("webId", Configuration.ApiClient.ParameterToString(webId));
            }
            localVarPostBody = Configuration.ApiClient.Serialize(unitDTO);
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            new HttpMethod("PATCH"), localVarQueryParams, localVarPostBody, localVarHeaderParams,
                                                                                            localVarPathParams);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("UpdateWithHttpInfo", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers,
                                            (Object)Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object))));
        }
示例#2
0
        public void UpdateTest()
        {
            PIUnit unitDTO = instance.Get(webId, null);

            unitDTO.WebId       = null;
            unitDTO.Id          = null;
            unitDTO.Factor      = null;
            unitDTO.Path        = null;
            unitDTO.Offset      = null;
            unitDTO.Links       = null;
            unitDTO.Description = "Updated description";
            instance.Update(webId, unitDTO);

            StandardPISystem.UOMDatabase.Refresh();
            string path   = Constants.AF_UOM_PATH;
            UOM    newUom = AFObject.FindObject(path) as UOM;

            if (newUom != null)
            {
                Assert.IsTrue(unitDTO.Description == newUom.Description);
            }
        }
示例#3
0
        /// <summary>
        /// Update a unit.
        /// </summary>
        /// <remarks>
        ///
        /// </remarks>
        /// <exception cref="OSIsoft.PIDevClub.PIWebApiClient.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="webId">The ID of the unit.</param>
        /// <param name="unitDTO">A partial unit containing the desired changes.</param>
        /// <param name="cancellationTokenSource">Signals to a CancellationToken that might be cancelled</param>
        /// <returns>async System.Threading.Tasks.Task<Object></returns>
        public async System.Threading.Tasks.Task <Object> UpdateAsync(string webId, PIUnit unitDTO, CancellationToken cancellationToken = default(CancellationToken))
        {
            ApiResponse <Object> localVarResponse = await UpdateAsyncWithHttpInfo(webId, unitDTO, cancellationToken);

            return(localVarResponse.Data);
        }