예제 #1
0
        internal virtual UpdateThingShadowResponse UpdateThingShadow(UpdateThingShadowRequest request)
        {
            var marshaller   = UpdateThingShadowRequestMarshaller.Instance;
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(Invoke <UpdateThingShadowRequest, UpdateThingShadowResponse>(request, marshaller, unmarshaller));
        }
예제 #2
0
        /// <summary>
        /// Updates the thing shadow for the specified thing.
        ///
        ///
        /// <para>
        /// For more information, see <a href="http://docs.aws.amazon.com/iot/latest/developerguide/API_UpdateThingShadow.html">UpdateThingShadow</a>
        /// in the <i>AWS IoT Developer Guide</i>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow service method.</param>
        ///
        /// <returns>The response from the UpdateThingShadow service method, as returned by IotData.</returns>
        /// <exception cref="Amazon.IotData.Model.ConflictException">
        /// The specified version does not match the version of the document.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.InternalFailureException">
        /// An unexpected error has occurred.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.InvalidRequestException">
        /// The request is not valid.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.MethodNotAllowedException">
        /// The specified combination of HTTP verb and URI is not supported.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.RequestEntityTooLargeException">
        /// The payload exceeds the maximum size allowed.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.ServiceUnavailableException">
        /// The service is temporarily unavailable.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.ThrottlingException">
        /// The rate exceeds the limit.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.UnauthorizedException">
        /// You are not authorized to perform this operation.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.UnsupportedDocumentEncodingException">
        /// The document encoding is not supported.
        /// </exception>
        public UpdateThingShadowResponse UpdateThingShadow(UpdateThingShadowRequest request)
        {
            var marshaller   = new UpdateThingShadowRequestMarshaller();
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(Invoke <UpdateThingShadowRequest, UpdateThingShadowResponse>(request, marshaller, unmarshaller));
        }
예제 #3
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateThingShadow operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow 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 virtual Task <UpdateThingShadowResponse> UpdateThingShadowAsync(UpdateThingShadowRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = UpdateThingShadowRequestMarshaller.Instance;
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateThingShadowRequest, UpdateThingShadowResponse>(request, marshaller,
                                                                                     unmarshaller, cancellationToken));
        }
예제 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateThingShadow operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow operation on AmazonIotDataClient.</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 EndUpdateThingShadow
        ///         operation.</returns>
        public IAsyncResult BeginUpdateThingShadow(UpdateThingShadowRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new UpdateThingShadowRequestMarshaller();
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(BeginInvoke <UpdateThingShadowRequest>(request, marshaller, unmarshaller,
                                                          callback, state));
        }
예제 #5
0
        /// <summary>
        /// Updates the thing shadow for the specified thing.
        ///
        ///
        /// <para>
        /// For more information, see <a href="http://docs.aws.amazon.com/iot/latest/developerguide/API_UpdateThingShadow.html">UpdateThingShadow</a>
        /// in the <i>AWS IoT Developer Guide</i>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow 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 UpdateThingShadow service method, as returned by IotData.</returns>
        /// <exception cref="Amazon.IotData.Model.ConflictException">
        /// The specified version does not match the version of the document.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.InternalFailureException">
        /// An unexpected error has occurred.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.InvalidRequestException">
        /// The request is not valid.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.MethodNotAllowedException">
        /// The specified combination of HTTP verb and URI is not supported.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.RequestEntityTooLargeException">
        /// The payload exceeds the maximum size allowed.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.ServiceUnavailableException">
        /// The service is temporarily unavailable.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.ThrottlingException">
        /// The rate exceeds the limit.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.UnauthorizedException">
        /// You are not authorized to perform this operation.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.UnsupportedDocumentEncodingException">
        /// The document encoding is not supported.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/iot-data-2015-05-28/UpdateThingShadow">REST API Reference for UpdateThingShadow Operation</seealso>
        public virtual Task <UpdateThingShadowResponse> UpdateThingShadowAsync(UpdateThingShadowRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateThingShadowRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateThingShadowResponse>(request, options, cancellationToken));
        }
예제 #6
0
        internal virtual UpdateThingShadowResponse UpdateThingShadow(UpdateThingShadowRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateThingShadowRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(Invoke <UpdateThingShadowResponse>(request, options));
        }
예제 #7
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateThingShadow operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow operation on AmazonIotDataClient.</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 EndUpdateThingShadow
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/iot-data-2015-05-28/UpdateThingShadow">REST API Reference for UpdateThingShadow Operation</seealso>
        public virtual IAsyncResult BeginUpdateThingShadow(UpdateThingShadowRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateThingShadowRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
예제 #8
0
        public ActionResult Select(string devName)
        {
            string jsonStr = string.Format(UPDATE_JSON_TEMPLATE, Request["emoji"]);
            UpdateThingShadowRequest req = new UpdateThingShadowRequest();

            req.ThingName = devName;
            req.Payload   = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
            UpdateThingShadowResponse res = _client.UpdateThingShadow(req);
            string state = Encoding.UTF8.GetString(res.Payload.ToArray());

            return(Content(Request["callback"] + "(" + state + ")"));
        }
        private void UpdateDevice(string location, string payload)
        {
            UpdateThingShadowRequest updateRequest = new UpdateThingShadowRequest();

            updateRequest.Payload = new MemoryStream(Encoding.UTF8.GetBytes(payload));

            // "store1_aisle1"
            updateRequest.ThingName = GetIotDeviceName(location);

            var response = _client.UpdateThingShadowAsync(updateRequest, new System.Threading.CancellationToken());

            response.Wait();
        }
예제 #10
0
 private async Task Connect(string thingName, bool isConnected)
 {
     try
     {
         string jsonStr = string.Format(CONNECT_JSON_TEMPLATE, isConnected ? "true" : "false");
         UpdateThingShadowRequest req = new UpdateThingShadowRequest();
         req.ThingName = thingName;
         req.Payload   = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
         UpdateThingShadowResponse res = await _client.UpdateThingShadowAsync(req);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
예제 #11
0
        public async Task UpdateThingShadow(ThingShadow <T> thingShadow)
        {
            var updateThingShadowRequest = new UpdateThingShadowRequest()
            {
                ThingName = this.thingName,
                Payload   = Utils.ToJsonMemoryStream(thingShadow)
            };

            var result = await this.client.UpdateThingShadowAsync(updateThingShadowRequest);

            if (result.HttpStatusCode != HttpStatusCode.OK)
            {
                throw new ThingShadowUpdateFailedException($"Received HTTP {result.HttpStatusCode}");
            }
        }
예제 #12
0
        private async Task Update(string thingName, string emoji, bool isDesired = false)
        {
            try
            {
                string jsonStr = string.Format(UPDATE_JSON_TEMPLATE, isDesired ? "desired" : "reported", emoji);

                UpdateThingShadowRequest req = new UpdateThingShadowRequest();
                req.ThingName = thingName;
                req.Payload   = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
                UpdateThingShadowResponse res = await _client.UpdateThingShadowAsync(req);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
예제 #13
0
 /// <summary>
 ///  更新设备影子的期望值
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <UpdateThingShadowResponse> UpdateThingShadow(UpdateThingShadowRequest request)
 {
     return(await new UpdateThingShadowExecutor().Client(this).Execute <UpdateThingShadowResponse, UpdateThingShadowResult, UpdateThingShadowRequest>(request).ConfigureAwait(false));
 }
예제 #14
0
 /// <summary>
 ///  更新设备影子的期望值
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public UpdateThingShadowResponse UpdateThingShadow(UpdateThingShadowRequest request)
 {
     return(new UpdateThingShadowExecutor().Client(this).Execute <UpdateThingShadowResponse, UpdateThingShadowResult, UpdateThingShadowRequest>(request));
 }
예제 #15
0
        public void Start()
        {
            AmazonIotDataConfig amazonIotDataConfig = new AmazonIotDataConfig();

            amazonIotDataConfig.RegionEndpoint = RegionEndpoint.EUWest1;
            //amazonIotDataConfig.UseHttp = false;
            //amazonIotDataConfig.SignatureVersion = "4";
            amazonIotDataConfig.ServiceURL = amazonIotDataConfig.DetermineServiceURL();

            Client = new AmazonIotDataClient(awsAccessKeyId, awsSecretAccessKey, amazonIotDataConfig);


            Monitorings = new List <Monitoring>();


            HardDriveSmartMonitoring hardDriveSmartMonitoring = new HardDriveSmartMonitoring((data) =>
            {
                var payload = new
                {
                    state = new
                    {
                        reported = new
                        {
                            Monitoring = new
                            {
                                HardDriveSmart = data
                            }
                        }
                    }
                };


                var request       = new UpdateThingShadowRequest();
                request.ThingName = thingName;
                request.Payload   = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));

                var response = Client.UpdateThingShadow(request);
            });

            Monitorings.Add(hardDriveSmartMonitoring);


            HardDriveSpaceMonitoring hardDriveSpaceMonitoring = new HardDriveSpaceMonitoring((data) =>
            {
                var payload = new
                {
                    state = new
                    {
                        reported = new
                        {
                            Monitoring = new
                            {
                                HardDriveSpace = data
                            }
                        }
                    }
                };


                var request       = new UpdateThingShadowRequest();
                request.ThingName = thingName;
                request.Payload   = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(payload)));

                var response = Client.UpdateThingShadow(request);
            });

            Monitorings.Add(hardDriveSpaceMonitoring);


            Monitorings.ForEach((monitoring) => monitoring.Start());
        }