| | 1 | | // <auto-generated> |
| | 2 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | 3 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | 4 | | // regenerated. |
| | 5 | | // </auto-generated> |
| | 6 | |
|
| | 7 | | namespace Microsoft.Azure.CognitiveServices.Search.VisualSearch |
| | 8 | | { |
| | 9 | | using Models; |
| | 10 | | using System.IO; |
| | 11 | | using System.Threading; |
| | 12 | | using System.Threading.Tasks; |
| | 13 | |
|
| | 14 | | /// <summary> |
| | 15 | | /// Extension methods for Images. |
| | 16 | | /// </summary> |
| | 17 | | public static partial class ImagesExtensions |
| | 18 | | { |
| | 19 | | /// <summary> |
| | 20 | | /// Visual Search API lets you discover insights about an image such as |
| | 21 | | /// visually similar images, shopping sources, and related searches. The API |
| | 22 | | /// can also perform text recognition, identify entities (people, places, |
| | 23 | | /// things), return other topical content for the user to explore, and more. |
| | 24 | | /// For more information, see [Visual Search |
| | 25 | | /// Overview](https://docs.microsoft.com/azure/cognitive-services/bing-visual-search/overview). |
| | 26 | | /// </summary> |
| | 27 | | /// <param name='operations'> |
| | 28 | | /// The operations group for this extension method. |
| | 29 | | /// </param> |
| | 30 | | /// <param name='acceptLanguage'> |
| | 31 | | /// A comma-delimited list of one or more languages to use for user interface |
| | 32 | | /// strings. The list is in decreasing order of preference. For additional |
| | 33 | | /// information, including expected format, see |
| | 34 | | /// [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This |
| | 35 | | /// header and the |
| | 36 | | /// [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-visual-search-api-v7-referenc |
| | 37 | | /// query parameter are mutually exclusive; do not specify both. If you set |
| | 38 | | /// this header, you must also specify the |
| | 39 | | /// [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-visual-search-api-v7-reference#cc) |
| | 40 | | /// query parameter. To determine the market to return results for, Bing uses |
| | 41 | | /// the first supported language it finds from the list and combines it with |
| | 42 | | /// the cc parameter value. If the list does not include a supported language, |
| | 43 | | /// Bing finds the closest language and market that supports the request or it |
| | 44 | | /// uses an aggregated or default market for the results. To determine the |
| | 45 | | /// market that Bing used, see the BingAPIs-Market header. Use this header and |
| | 46 | | /// the cc query parameter only if you specify multiple languages. Otherwise, |
| | 47 | | /// use the |
| | 48 | | /// [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-visual-search-api-v7-reference#mk |
| | 49 | | /// and |
| | 50 | | /// [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-visual-search-api-v7-referenc |
| | 51 | | /// query parameters. A user interface string is a string that's used as a |
| | 52 | | /// label in a user interface. There are few user interface strings in the JSON |
| | 53 | | /// response objects. Any links to Bing.com properties in the response objects |
| | 54 | | /// apply the specified language. |
| | 55 | | /// </param> |
| | 56 | | /// <param name='contentType'> |
| | 57 | | /// Must be set to multipart/form-data and include a boundary parameter (for |
| | 58 | | /// example, multipart/form-data; boundary=<boundary string>). For more |
| | 59 | | /// details, see [Content form types]( |
| | 60 | | /// https://docs.microsoft.com/en-us/azure/cognitive-services/bing-visual-search/overview#content-form-types |
| | 61 | | /// </param> |
| | 62 | | /// <param name='userAgent'> |
| | 63 | | /// The user agent originating the request. Bing uses the user agent to provide |
| | 64 | | /// mobile users with an optimized experience. Although optional, you are |
| | 65 | | /// encouraged to always specify this header. The user-agent should be the same |
| | 66 | | /// string that any commonly used browser sends. For information about user |
| | 67 | | /// agents, see [RFC |
| | 68 | | /// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The |
| | 69 | | /// following are examples of user-agent strings. Windows Phone: Mozilla/5.0 |
| | 70 | | /// (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; |
| | 71 | | /// Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; |
| | 72 | | /// en - us; SCH - I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like |
| | 73 | | /// Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; |
| | 74 | | /// CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) |
| | 75 | | /// Mobile / 10B142 iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 |
| | 76 | | /// (Windows NT 6.3; WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: |
| | 77 | | /// Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 |
| | 78 | | /// (KHTML, like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53. |
| | 79 | | /// </param> |
| | 80 | | /// <param name='clientId'> |
| | 81 | | /// Bing uses this header to provide users with consistent behavior across Bing |
| | 82 | | /// API calls. Bing often flights new features and improvements, and it uses |
| | 83 | | /// the client ID as a key for assigning traffic on different flights. If you |
| | 84 | | /// do not use the same client ID for a user across multiple requests, then |
| | 85 | | /// Bing may assign the user to multiple conflicting flights. Being assigned to |
| | 86 | | /// multiple conflicting flights can lead to an inconsistent user experience. |
| | 87 | | /// For example, if the second request has a different flight assignment than |
| | 88 | | /// the first, the experience may be unexpected. Also, Bing can use the client |
| | 89 | | /// ID to tailor web results to that client ID’s search history, providing a |
| | 90 | | /// richer experience for the user. Bing also uses this header to help improve |
| | 91 | | /// result rankings by analyzing the activity generated by a client ID. The |
| | 92 | | /// relevance improvements help with better quality of results delivered by |
| | 93 | | /// Bing APIs and in turn enables higher click-through rates for the API |
| | 94 | | /// consumer. IMPORTANT: Although optional, you should consider this header |
| | 95 | | /// required. Persisting the client ID across multiple requests for the same |
| | 96 | | /// end user and device combination enables 1) the API consumer to receive a |
| | 97 | | /// consistent user experience, and 2) higher click-through rates via better |
| | 98 | | /// quality of results from the Bing APIs. Each user that uses your application |
| | 99 | | /// on the device must have a unique, Bing generated client ID. If you do not |
| | 100 | | /// include this header in the request, Bing generates an ID and returns it in |
| | 101 | | /// the X-MSEdge-ClientID response header. The only time that you should NOT |
| | 102 | | /// include this header in a request is the first time the user uses your app |
| | 103 | | /// on that device. Use the client ID for each Bing API request that your app |
| | 104 | | /// makes for this user on the device. Persist the client ID. To persist the ID |
| | 105 | | /// in a browser app, use a persistent HTTP cookie to ensure the ID is used |
| | 106 | | /// across all sessions. Do not use a session cookie. For other apps such as |
| | 107 | | /// mobile apps, use the device's persistent storage to persist the ID. The |
| | 108 | | /// next time the user uses your app on that device, get the client ID that you |
| | 109 | | /// persisted. Bing responses may or may not include this header. If the |
| | 110 | | /// response includes this header, capture the client ID and use it for all |
| | 111 | | /// subsequent Bing requests for the user on that device. ATTENTION: You must |
| | 112 | | /// ensure that this Client ID is not linkable to any authenticatable user |
| | 113 | | /// account information. If you include the X-MSEdge-ClientID, you must not |
| | 114 | | /// include cookies in the request. |
| | 115 | | /// </param> |
| | 116 | | /// <param name='clientIp'> |
| | 117 | | /// The IPv4 or IPv6 address of the client device. The IP address is used to |
| | 118 | | /// discover the user's location. Bing uses the location information to |
| | 119 | | /// determine safe search behavior. Although optional, you are encouraged to |
| | 120 | | /// always specify this header and the X-Search-Location header. Do not |
| | 121 | | /// obfuscate the address (for example, by changing the last octet to 0). |
| | 122 | | /// Obfuscating the address results in the location not being anywhere near the |
| | 123 | | /// device's actual location, which may result in Bing serving erroneous |
| | 124 | | /// results. |
| | 125 | | /// </param> |
| | 126 | | /// <param name='location'> |
| | 127 | | /// A semicolon-delimited list of key/value pairs that describe the client's |
| | 128 | | /// geographical location. Bing uses the location information to determine safe |
| | 129 | | /// search behavior and to return relevant local content. Specify the key/value |
| | 130 | | /// pair as <key>:<value>. The following are the keys that you use |
| | 131 | | /// to specify the user's location. lat (required): The latitude of the |
| | 132 | | /// client's location, in degrees. The latitude must be greater than or equal |
| | 133 | | /// to -90.0 and less than or equal to +90.0. Negative values indicate southern |
| | 134 | | /// latitudes and positive values indicate northern latitudes. long (required): |
| | 135 | | /// The longitude of the client's location, in degrees. The longitude must be |
| | 136 | | /// greater than or equal to -180.0 and less than or equal to +180.0. Negative |
| | 137 | | /// values indicate western longitudes and positive values indicate eastern |
| | 138 | | /// longitudes. re (required): The radius, in meters, which specifies the |
| | 139 | | /// horizontal accuracy of the coordinates. Pass the value returned by the |
| | 140 | | /// device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m |
| | 141 | | /// for cell tower triangulation, and 18,000m for reverse IP lookup. ts |
| | 142 | | /// (optional): The UTC UNIX timestamp of when the client was at the location. |
| | 143 | | /// (The UNIX timestamp is the number of seconds since January 1, 1970.) head |
| | 144 | | /// (optional): The client's relative heading or direction of travel. Specify |
| | 145 | | /// the direction of travel as degrees from 0 through 360, counting clockwise |
| | 146 | | /// relative to true north. Specify this key only if the sp key is nonzero. sp |
| | 147 | | /// (optional): The horizontal velocity (speed), in meters per second, that the |
| | 148 | | /// client device is traveling. alt (optional): The altitude of the client |
| | 149 | | /// device, in meters. are (optional): The radius, in meters, that specifies |
| | 150 | | /// the vertical accuracy of the coordinates. Specify this key only if you |
| | 151 | | /// specify the alt key. Although many of the keys are optional, the more |
| | 152 | | /// information that you provide, the more accurate the location results are. |
| | 153 | | /// Although optional, you are encouraged to always specify the user's |
| | 154 | | /// geographical location. Providing the location is especially important if |
| | 155 | | /// the client's IP address does not accurately reflect the user's physical |
| | 156 | | /// location (for example, if the client uses VPN). For optimal results, you |
| | 157 | | /// should include this header and the X-MSEdge-ClientIP header, but at a |
| | 158 | | /// minimum, you should include this header. |
| | 159 | | /// </param> |
| | 160 | | /// <param name='market'> |
| | 161 | | /// The market where the results come from. Typically, mkt is the country where |
| | 162 | | /// the user is making the request from. However, it could be a different |
| | 163 | | /// country if the user is not located in a country where Bing delivers |
| | 164 | | /// results. The market must be in the form <language code>-<country |
| | 165 | | /// code>. For example, en-US. The string is case insensitive. For a list of |
| | 166 | | /// possible market values, see [Market |
| | 167 | | /// Codes](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-visual-search/supported-countries- |
| | 168 | | /// NOTE: If known, you are encouraged to always specify the market. Specifying |
| | 169 | | /// the market helps Bing route the request and return an appropriate and |
| | 170 | | /// optimal response. If you specify a market that is not listed in [Market |
| | 171 | | /// Codes](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-visual-search/supported-countries- |
| | 172 | | /// Bing uses a best fit market code based on an internal mapping that is |
| | 173 | | /// subject to change. |
| | 174 | | /// </param> |
| | 175 | | /// <param name='safeSearch'> |
| | 176 | | /// Filter the image results in actions with type 'VisualSearch' for adult |
| | 177 | | /// content. The following are the possible filter values. Off: May return |
| | 178 | | /// images with adult content. Moderate: Do not return images with adult |
| | 179 | | /// content. Strict: Do not return images with adult content. The default is |
| | 180 | | /// Moderate. If the request comes from a market that Bing's adult policy |
| | 181 | | /// requires that safeSearch is set to Strict, Bing ignores the safeSearch |
| | 182 | | /// value and uses Strict. If you use the site: filter in the knowledge |
| | 183 | | /// request, there is the chance that the response may contain adult content |
| | 184 | | /// regardless of what the safeSearch query parameter is set to. Use site: only |
| | 185 | | /// if you are aware of the content on the site and your scenario supports the |
| | 186 | | /// possibility of adult content. Possible values include: 'Off', 'Moderate', |
| | 187 | | /// 'Strict' |
| | 188 | | /// </param> |
| | 189 | | /// <param name='setLang'> |
| | 190 | | /// The language to use for user interface strings. Specify the language using |
| | 191 | | /// the ISO 639-1 2-letter language code. For example, the language code for |
| | 192 | | /// English is EN. The default is EN (English). Although optional, you should |
| | 193 | | /// always specify the language. Typically, you set setLang to the same |
| | 194 | | /// language specified by mkt unless the user wants the user interface strings |
| | 195 | | /// displayed in a different language. A user interface string is a string |
| | 196 | | /// that's used as a label in a user interface. There are few user interface |
| | 197 | | /// strings in the JSON response objects. Also, any links to Bing.com |
| | 198 | | /// properties in the response objects apply the specified language. |
| | 199 | | /// </param> |
| | 200 | | /// <param name='knowledgeRequest'> |
| | 201 | | /// The form data is a JSON object that identifies the image using an insights |
| | 202 | | /// token or URL to the image. The object may also include an optional crop |
| | 203 | | /// area that identifies an area of interest in the image. The insights token |
| | 204 | | /// and URL are mutually exclusive – do not specify both. You may specify |
| | 205 | | /// knowledgeRequest form data and image form data in the same request only if |
| | 206 | | /// knowledgeRequest form data specifies the cropArea field only (it must not |
| | 207 | | /// include an insights token or URL). |
| | 208 | | /// </param> |
| | 209 | | /// <param name='image'> |
| | 210 | | /// The form data is an image binary. The Content-Disposition header's name |
| | 211 | | /// parameter must be set to "image". You must specify an image binary if you |
| | 212 | | /// do not use knowledgeRequest form data to specify the image; you may not use |
| | 213 | | /// both forms to specify an image. You may specify knowledgeRequest form data |
| | 214 | | /// and image form data in the same request only if knowledgeRequest form data |
| | 215 | | /// specifies the cropArea field only (it must not include an insights token |
| | 216 | | /// or URL). |
| | 217 | | /// </param> |
| | 218 | | /// <param name='cancellationToken'> |
| | 219 | | /// The cancellation token. |
| | 220 | | /// </param> |
| | 221 | | public static async Task<ImageKnowledge> VisualSearchMethodAsync(this IImages operations, string acceptLangu |
| | 222 | | { |
| 3 | 223 | | using (var _result = await operations.VisualSearchMethodWithHttpMessagesAsync(acceptLanguage, contentTyp |
| | 224 | | { |
| 3 | 225 | | return _result.Body; |
| | 226 | | } |
| 3 | 227 | | } |
| | 228 | |
|
| | 229 | | } |
| | 230 | | } |