Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public void CustomImageSearch()
{
HttpMockServer.Initialize(this.GetType().FullName, "CustomImageSearch");

var client = new CustomImageSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());
var resp = client.CustomInstance.ImageSearchAsync(query: "tom cruise", customConfig: 0).Result;
var client = new CustomImageSearchClient(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance());
var resp = client.CustomInstance.ImageSearchAsync(query: "tom cruise", customConfig: "0").Result;

Assert.NotNull(resp);
Assert.NotNull(resp.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.Azure.CognitiveServices.Search.CustomImageSearch
/// Bing and get back image search results customized to meet your custom
/// search definition.
/// </summary>
public partial class CustomImageSearchAPI : ServiceClient<CustomImageSearchAPI>, ICustomImageSearchAPI
public partial class CustomImageSearchClient : ServiceClient<CustomImageSearchClient>, ICustomImageSearchClient
{
/// <summary>
/// The base URI of the service.
Expand Down Expand Up @@ -48,32 +48,45 @@ public partial class CustomImageSearchAPI : ServiceClient<CustomImageSearchAPI>,
public virtual ICustomInstance CustomInstance { get; private set; }

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='httpClient'>
/// HttpClient to be used
/// </param>
/// <param name='disposeHttpClient'>
/// True: will dispose the provided httpClient on calling CustomImageSearchClient.Dispose(). False: will not dispose provided httpClient</param>
protected CustomImageSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
{
Initialize();
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
protected CustomImageSearchAPI(params DelegatingHandler[] handlers) : base(handlers)
protected CustomImageSearchClient(params DelegatingHandler[] handlers) : base(handlers)
{
Initialize();
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
protected CustomImageSearchAPI(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
protected CustomImageSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
{
Initialize();
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
Expand All @@ -84,7 +97,7 @@ protected CustomImageSearchAPI(HttpClientHandler rootHandler, params DelegatingH
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected CustomImageSearchAPI(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
protected CustomImageSearchClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
{
if (baseUri == null)
{
Expand All @@ -94,7 +107,7 @@ protected CustomImageSearchAPI(System.Uri baseUri, params DelegatingHandler[] ha
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
Expand All @@ -108,7 +121,7 @@ protected CustomImageSearchAPI(System.Uri baseUri, params DelegatingHandler[] ha
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
protected CustomImageSearchAPI(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
protected CustomImageSearchClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (baseUri == null)
{
Expand All @@ -118,7 +131,7 @@ protected CustomImageSearchAPI(System.Uri baseUri, HttpClientHandler rootHandler
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
Expand All @@ -129,7 +142,34 @@ protected CustomImageSearchAPI(System.Uri baseUri, HttpClientHandler rootHandler
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public CustomImageSearchAPI(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
public CustomImageSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
{
if (credentials == null)
{
throw new System.ArgumentNullException("credentials");
}
Credentials = credentials;
if (Credentials != null)
{
Credentials.InitializeServiceClient(this);
}
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
/// </param>
/// <param name='httpClient'>
/// HttpClient to be used
/// </param>
/// <param name='disposeHttpClient'>
/// True: will dispose the provided httpClient on calling CustomImageSearchClient.Dispose(). False: will not dispose provided httpClient</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public CustomImageSearchClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
{
if (credentials == null)
{
Expand All @@ -143,7 +183,7 @@ public CustomImageSearchAPI(ServiceClientCredentials credentials, params Delegat
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
Expand All @@ -157,7 +197,7 @@ public CustomImageSearchAPI(ServiceClientCredentials credentials, params Delegat
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public CustomImageSearchAPI(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
public CustomImageSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (credentials == null)
{
Expand All @@ -171,7 +211,7 @@ public CustomImageSearchAPI(ServiceClientCredentials credentials, HttpClientHand
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
Expand All @@ -185,7 +225,7 @@ public CustomImageSearchAPI(ServiceClientCredentials credentials, HttpClientHand
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public CustomImageSearchAPI(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
public CustomImageSearchClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
{
if (baseUri == null)
{
Expand All @@ -204,7 +244,7 @@ public CustomImageSearchAPI(System.Uri baseUri, ServiceClientCredentials credent
}

/// <summary>
/// Initializes a new instance of the CustomImageSearchAPI class.
/// Initializes a new instance of the CustomImageSearchClient class.
/// </summary>
/// <param name='baseUri'>
/// Optional. The base URI of the service.
Expand All @@ -221,7 +261,7 @@ public CustomImageSearchAPI(System.Uri baseUri, ServiceClientCredentials credent
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public CustomImageSearchAPI(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
public CustomImageSearchClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
{
if (baseUri == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.Azure.CognitiveServices.Search.CustomImageSearch
/// <summary>
/// CustomInstance operations.
/// </summary>
public partial class CustomInstance : IServiceOperations<CustomImageSearchAPI>, ICustomInstance
public partial class CustomInstance : IServiceOperations<CustomImageSearchClient>, ICustomInstance
{
/// <summary>
/// Initializes a new instance of the CustomInstance class.
Expand All @@ -32,7 +32,7 @@ public partial class CustomInstance : IServiceOperations<CustomImageSearchAPI>,
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public CustomInstance(CustomImageSearchAPI client)
public CustomInstance(CustomImageSearchClient client)
{
if (client == null)
{
Expand All @@ -42,9 +42,9 @@ public CustomInstance(CustomImageSearchAPI client)
}

/// <summary>
/// Gets a reference to the CustomImageSearchAPI
/// Gets a reference to the CustomImageSearchClient
/// </summary>
public CustomImageSearchAPI Client { get; private set; }
public CustomImageSearchClient Client { get; private set; }

/// <summary>
/// The Custom Image Search API lets you send an image search query to Bing and
Expand Down Expand Up @@ -425,11 +425,11 @@ public CustomInstance(CustomImageSearchAPI client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<Images>> ImageSearchWithHttpMessagesAsync(long customConfig, string query, string acceptLanguage = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), string aspect = default(string), string color = default(string), string countryCode = default(string), int? count = default(int?), string freshness = default(string), int? height = default(int?), string id = default(string), string imageContent = default(string), string imageType = default(string), string license = default(string), string market = default(string), long? maxFileSize = default(long?), long? maxHeight = default(long?), long? maxWidth = default(long?), long? minFileSize = default(long?), long? minHeight = default(long?), long? minWidth = default(long?), long? offset = default(long?), string safeSearch = default(string), string size = default(string), string setLang = default(string), int? width = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<Images>> ImageSearchWithHttpMessagesAsync(string customConfig, string query, string acceptLanguage = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), string aspect = default(string), string color = default(string), string countryCode = default(string), int? count = default(int?), string freshness = default(string), int? height = default(int?), string id = default(string), string imageContent = default(string), string imageType = default(string), string license = default(string), string market = default(string), long? maxFileSize = default(long?), long? maxHeight = default(long?), long? maxWidth = default(long?), long? minFileSize = default(long?), long? minHeight = default(long?), long? minWidth = default(long?), long? offset = default(long?), string safeSearch = default(string), string size = default(string), string setLang = default(string), int? width = default(int?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (customConfig < 0)
if (customConfig == null)
{
throw new ValidationException(ValidationRules.InclusiveMinimum, "customConfig", 0);
throw new ValidationException(ValidationRules.CannotBeNull, "customConfig");
}
if (query == null)
{
Expand Down Expand Up @@ -480,7 +480,10 @@ public CustomInstance(CustomImageSearchAPI client)
var _baseUrl = Client.BaseUri.AbsoluteUri;
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "images/search").ToString();
List<string> _queryParameters = new List<string>();
_queryParameters.Add(string.Format("customConfig={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(customConfig, Client.SerializationSettings).Trim('"'))));
if (customConfig != null)
{
_queryParameters.Add(string.Format("customConfig={0}", System.Uri.EscapeDataString(customConfig)));
}
if (aspect != null)
{
_queryParameters.Add(string.Format("aspect={0}", System.Uri.EscapeDataString(aspect)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public static partial class CustomInstanceExtensions
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<Images> ImageSearchAsync(this ICustomInstance operations, long customConfig, string query, string acceptLanguage = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), string aspect = default(string), string color = default(string), string countryCode = default(string), int? count = default(int?), string freshness = default(string), int? height = default(int?), string id = default(string), string imageContent = default(string), string imageType = default(string), string license = default(string), string market = default(string), long? maxFileSize = default(long?), long? maxHeight = default(long?), long? maxWidth = default(long?), long? minFileSize = default(long?), long? minHeight = default(long?), long? minWidth = default(long?), long? offset = default(long?), string safeSearch = default(string), string size = default(string), string setLang = default(string), int? width = default(int?), CancellationToken cancellationToken = default(CancellationToken))
public static async Task<Images> ImageSearchAsync(this ICustomInstance operations, string customConfig, string query, string acceptLanguage = default(string), string userAgent = default(string), string clientId = default(string), string clientIp = default(string), string location = default(string), string aspect = default(string), string color = default(string), string countryCode = default(string), int? count = default(int?), string freshness = default(string), int? height = default(int?), string id = default(string), string imageContent = default(string), string imageType = default(string), string license = default(string), string market = default(string), long? maxFileSize = default(long?), long? maxHeight = default(long?), long? maxWidth = default(long?), long? minFileSize = default(long?), long? minHeight = default(long?), long? minWidth = default(long?), long? offset = default(long?), string safeSearch = default(string), string size = default(string), string setLang = default(string), int? width = default(int?), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ImageSearchWithHttpMessagesAsync(customConfig, query, acceptLanguage, userAgent, clientId, clientIp, location, aspect, color, countryCode, count, freshness, height, id, imageContent, imageType, license, market, maxFileSize, maxHeight, maxWidth, minFileSize, minHeight, minWidth, offset, safeSearch, size, setLang, width, null, cancellationToken).ConfigureAwait(false))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.Azure.CognitiveServices.Search.CustomImageSearch
/// Bing and get back image search results customized to meet your custom
/// search definition.
/// </summary>
public partial interface ICustomImageSearchAPI : System.IDisposable
public partial interface ICustomImageSearchClient : System.IDisposable
{
/// <summary>
/// The base URI of the service.
Expand Down
Loading