/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using Amazon.Runtime;
using Amazon.MachineLearning.Model;
using System.Collections.Generic;
namespace Amazon.MachineLearning.Util
{
///
/// A simplified client that just does realtime predictions.
///
public partial class RealtimePredictor : IDisposable
{
private bool shouldDispose = false;
private bool isDisposed = false;
private IAmazonMachineLearning client;
private string endpoint = null;
///
/// Constructs a RealtimePredictor which will use the passed in client to make requests.
///
///
/// The endpoint URL will be determined my making a service call to retrieve it.
///
/// The MachineLearning client that will be used to make requests.
/// The MachineLearning model to predict against.
public RealtimePredictor(IAmazonMachineLearning client, string modelId)
{
this.client = client;
this.ModelId = modelId;
}
///
/// Constructs a RealtimePredictor which will use the passed in client to make requests.
///
/// The MachineLearning client that will be used to make requests.
/// The MachineLearning model to predict against.
/// The endpoint to send requests to.
public RealtimePredictor(IAmazonMachineLearning client, string modelId, string endpoint)
{
this.client = client;
this.ModelId = modelId;
this.endpoint = endpoint;
}
///
/// The Id of the MachineLearning model.
///
public string ModelId { get; private set; }
#region Dispose Pattern Implementation
///
/// Implements the Dispose pattern
///
/// Whether this object is being disposed via a call to Dispose
/// or garbage collected.
protected virtual void Dispose(bool disposing)
{
if (!isDisposed)
{
if (disposing && client != null && shouldDispose)
{
client.Dispose();
client = null;
}
isDisposed = true;
}
}
///
/// Disposes of all managed and unmanaged resources.
///
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}