diff --git a/sdk/maps/Azure.Maps.Search/src/Generated/SearchRestClient.cs b/sdk/maps/Azure.Maps.Search/src/Generated/SearchRestClient.cs index 89423ce39830..9d74d289c354 100644 --- a/sdk/maps/Azure.Maps.Search/src/Generated/SearchRestClient.cs +++ b/sdk/maps/Azure.Maps.Search/src/Generated/SearchRestClient.cs @@ -50,7 +50,7 @@ public SearchRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeli _clientId = clientId; } - internal HttpMessage CreateGetGeocodingRequest(int? top, string query, string addressLine, string countryRegion, IEnumerable boundingBox, string view, IEnumerable coordinates, string adminDistrict, string adminDistrict2, string adminDistrict3, string locality, string postalCode) + internal HttpMessage CreateGetGeocodingRequest(int? top, string query, string addressLine, string countryRegion, IEnumerable boundingBox, string view, IEnumerable coordinates, string adminDistrict, string adminDistrict2, string adminDistrict3, string locality, string postalCode, string acceptLanguage) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -108,10 +108,13 @@ internal HttpMessage CreateGetGeocodingRequest(int? top, string query, string ad uri.AppendQuery("postalCode", postalCode, true); } request.Uri = uri; - if (_acceptLanguage != null) + + acceptLanguage ??= _acceptLanguage; + if (acceptLanguage != null) { - request.Headers.Add("Accept-Language", _acceptLanguage); + request.Headers.Add("Accept-Language", acceptLanguage); } + if (_clientId != null) { request.Headers.Add("x-ms-client-id", _clientId); @@ -175,10 +178,14 @@ internal HttpMessage CreateGetGeocodingRequest(int? top, string query, string ad /// /// **If query is given, should not use this parameter.** /// + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// /// The cancellation token to use. - public async Task> GetGeocodingAsync(int? top = null, string query = null, string addressLine = null, string countryRegion = null, IEnumerable boundingBox = null, string view = null, IEnumerable coordinates = null, string adminDistrict = null, string adminDistrict2 = null, string adminDistrict3 = null, string locality = null, string postalCode = null, CancellationToken cancellationToken = default) + public async Task> GetGeocodingAsync(int? top = null, string query = null, string addressLine = null, string countryRegion = null, IEnumerable boundingBox = null, string view = null, IEnumerable coordinates = null, string adminDistrict = null, string adminDistrict2 = null, string adminDistrict3 = null, string locality = null, string postalCode = null, string acceptLanguage = null, CancellationToken cancellationToken = default) { - using var message = CreateGetGeocodingRequest(top, query, addressLine, countryRegion, boundingBox, view, coordinates, adminDistrict, adminDistrict2, adminDistrict3, locality, postalCode); + using var message = CreateGetGeocodingRequest(top, query, addressLine, countryRegion, boundingBox, view, coordinates, adminDistrict, adminDistrict2, adminDistrict3, locality, postalCode, acceptLanguage); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -249,10 +256,14 @@ public async Task> GetGeocodingAsync(int? top = null /// /// **If query is given, should not use this parameter.** /// + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// /// The cancellation token to use. - public Response GetGeocoding(int? top = null, string query = null, string addressLine = null, string countryRegion = null, IEnumerable boundingBox = null, string view = null, IEnumerable coordinates = null, string adminDistrict = null, string adminDistrict2 = null, string adminDistrict3 = null, string locality = null, string postalCode = null, CancellationToken cancellationToken = default) + public Response GetGeocoding(int? top = null, string query = null, string addressLine = null, string countryRegion = null, IEnumerable boundingBox = null, string view = null, IEnumerable coordinates = null, string adminDistrict = null, string adminDistrict2 = null, string adminDistrict3 = null, string locality = null, string postalCode = null, string acceptLanguage = null, CancellationToken cancellationToken = default) { - using var message = CreateGetGeocodingRequest(top, query, addressLine, countryRegion, boundingBox, view, coordinates, adminDistrict, adminDistrict2, adminDistrict3, locality, postalCode); + using var message = CreateGetGeocodingRequest(top, query, addressLine, countryRegion, boundingBox, view, coordinates, adminDistrict, adminDistrict2, adminDistrict3, locality, postalCode, acceptLanguage); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -450,7 +461,7 @@ public Response GetGeocodingBatch(GeocodingBatchRequestB } } - internal HttpMessage CreateGetPolygonRequest(IEnumerable coordinates, string view, BoundaryResultTypeEnum? resultType, ResolutionEnum? resolution) + internal HttpMessage CreateGetPolygonRequest(IEnumerable coordinates, string view, BoundaryResultTypeEnum? resultType, ResolutionEnum? resolution, string acceptLanguage) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -480,9 +491,10 @@ internal HttpMessage CreateGetPolygonRequest(IEnumerable coordinates, st { request.Headers.Add("x-ms-client-id", _clientId); } - if (_acceptLanguage != null) + acceptLanguage ??= _acceptLanguage; + if (acceptLanguage != null) { - request.Headers.Add("Accept-Language", _acceptLanguage); + request.Headers.Add("Accept-Language", acceptLanguage); } request.Headers.Add("Accept", "application/geo+json, application/json"); return message; @@ -504,15 +516,19 @@ internal HttpMessage CreateGetPolygonRequest(IEnumerable coordinates, st /// The geopolitical concept to return a boundary for. /// Resolution determines the amount of points to send back. /// The cancellation token to use. + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// /// is null. - public async Task> GetPolygonAsync(IEnumerable coordinates, string view = null, BoundaryResultTypeEnum? resultType = null, ResolutionEnum? resolution = null, CancellationToken cancellationToken = default) + public async Task> GetPolygonAsync(IEnumerable coordinates, string view = null, BoundaryResultTypeEnum? resultType = null, ResolutionEnum? resolution = null, string acceptLanguage = null, CancellationToken cancellationToken = default) { if (coordinates == null) { throw new ArgumentNullException(nameof(coordinates)); } - using var message = CreateGetPolygonRequest(coordinates, view, resultType, resolution); + using var message = CreateGetPolygonRequest(coordinates, view, resultType, resolution, acceptLanguage); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -543,16 +559,20 @@ public async Task> GetPolygonAsync(IEnumerable /// The geopolitical concept to return a boundary for. /// Resolution determines the amount of points to send back. + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// /// The cancellation token to use. /// is null. - public Response GetPolygon(IEnumerable coordinates, string view = null, BoundaryResultTypeEnum? resultType = null, ResolutionEnum? resolution = null, CancellationToken cancellationToken = default) + public Response GetPolygon(IEnumerable coordinates, string view = null, BoundaryResultTypeEnum? resultType = null, ResolutionEnum? resolution = null, string acceptLanguage = null, CancellationToken cancellationToken = default) { if (coordinates == null) { throw new ArgumentNullException(nameof(coordinates)); } - using var message = CreateGetPolygonRequest(coordinates, view, resultType, resolution); + using var message = CreateGetPolygonRequest(coordinates, view, resultType, resolution, acceptLanguage); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { @@ -568,7 +588,7 @@ public Response GetPolygon(IEnumerable coordinates, st } } - internal HttpMessage CreateGetReverseGeocodingRequest(IEnumerable coordinates, IEnumerable resultTypes, string view) + internal HttpMessage CreateGetReverseGeocodingRequest(IEnumerable coordinates, IEnumerable resultTypes, string view, string acceptLanguage) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -594,9 +614,11 @@ internal HttpMessage CreateGetReverseGeocodingRequest(IEnumerable coordi { request.Headers.Add("x-ms-client-id", _clientId); } - if (_acceptLanguage != null) + + acceptLanguage ??= _acceptLanguage; + if (acceptLanguage != null) { - request.Headers.Add("Accept-Language", _acceptLanguage); + request.Headers.Add("Accept-Language", acceptLanguage); } request.Headers.Add("Accept", "application/geo+json, application/json"); return message; @@ -631,15 +653,19 @@ internal HttpMessage CreateGetReverseGeocodingRequest(IEnumerable coordi /// Please refer to [Supported Views](https://aka.ms/AzureMapsLocalizationViews) for details and to see the available Views. /// /// The cancellation token to use. + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// /// is null. - public async Task> GetReverseGeocodingAsync(IEnumerable coordinates, IEnumerable resultTypes = null, string view = null, CancellationToken cancellationToken = default) + public async Task> GetReverseGeocodingAsync(IEnumerable coordinates, IEnumerable resultTypes = null, string view = null, string acceptLanguage = null, CancellationToken cancellationToken = default) { if (coordinates == null) { throw new ArgumentNullException(nameof(coordinates)); } - using var message = CreateGetReverseGeocodingRequest(coordinates, resultTypes, view); + using var message = CreateGetReverseGeocodingRequest(coordinates, resultTypes, view, acceptLanguage); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -684,15 +710,19 @@ public async Task> GetReverseGeocodingAsync(IEnumera /// Please refer to [Supported Views](https://aka.ms/AzureMapsLocalizationViews) for details and to see the available Views. /// /// The cancellation token to use. + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// /// is null. - public Response GetReverseGeocoding(IEnumerable coordinates, IEnumerable resultTypes = null, string view = null, CancellationToken cancellationToken = default) + public Response GetReverseGeocoding(IEnumerable coordinates, IEnumerable resultTypes = null, string view = null, string acceptLanguage = null, CancellationToken cancellationToken = default) { if (coordinates == null) { throw new ArgumentNullException(nameof(coordinates)); } - using var message = CreateGetReverseGeocodingRequest(coordinates, resultTypes, view); + using var message = CreateGetReverseGeocodingRequest(coordinates, resultTypes, view, acceptLanguage); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { diff --git a/sdk/maps/Azure.Maps.Search/src/MapsSearchClient.cs b/sdk/maps/Azure.Maps.Search/src/MapsSearchClient.cs index 14863c5a6d42..a52a10911f97 100644 --- a/sdk/maps/Azure.Maps.Search/src/MapsSearchClient.cs +++ b/sdk/maps/Azure.Maps.Search/src/MapsSearchClient.cs @@ -165,7 +165,7 @@ public virtual async Task> GetGeocodingAsync(string }; } - return await RestClient.GetGeocodingAsync(options?.Top, query, options?.AddressLine, options?.CountryRegion, boundingBox, localizedMapView, coordinates, options?.AdminDistrict, options?.AdminDistrict2, options?.AdminDistrict3, options?.Locality, options?.PostalCode, cancellationToken).ConfigureAwait(false); + return await RestClient.GetGeocodingAsync(options?.Top, query, options?.AddressLine, options?.CountryRegion, boundingBox, localizedMapView, coordinates, options?.AdminDistrict, options?.AdminDistrict2, options?.AdminDistrict3, options?.Locality, options?.PostalCode, options?.AcceptLanguage, cancellationToken).ConfigureAwait(false); } catch (Exception e) { @@ -207,7 +207,7 @@ public virtual Response GetGeocoding(string query = null, Geo }; } - return RestClient.GetGeocoding(options?.Top, query, options?.AddressLine, options?.CountryRegion, boundingBox, localizedMapView, coordinates, options?.AdminDistrict, options?.AdminDistrict2, options?.AdminDistrict3, options?.Locality, options?.PostalCode, cancellationToken); + return RestClient.GetGeocoding(options?.Top, query, options?.AddressLine, options?.CountryRegion, boundingBox, localizedMapView, coordinates, options?.AdminDistrict, options?.AdminDistrict2, options?.AdminDistrict3, options?.Locality, options?.PostalCode, options?.AcceptLanguage, cancellationToken); } catch (Exception e) { @@ -284,7 +284,7 @@ public virtual async Task> GetPolygonAsync(GetPolygonOptions Convert.ToDouble(options.Coordinates.Longitude, CultureInfo.InvariantCulture.NumberFormat) }; } - var boundaryInternal = await RestClient.GetPolygonAsync(coordinates, localizedMapView, options?.ResultType, options?.Resolution, cancellationToken).ConfigureAwait(false); + var boundaryInternal = await RestClient.GetPolygonAsync(coordinates, localizedMapView, options?.ResultType, options?.Resolution, options?.AcceptLanguage, cancellationToken).ConfigureAwait(false); return Response.FromValue(new Boundary(boundaryInternal.Value), boundaryInternal.GetRawResponse()); } catch (Exception e) @@ -318,7 +318,7 @@ public virtual Response GetPolygon(GetPolygonOptions options = null, C { coordinates = new[] { (double)options.Coordinates.Longitude, (double)options.Coordinates.Latitude }; } - var boundaryInternal = RestClient.GetPolygon(coordinates, localizedMapView, options?.ResultType, options?.Resolution, cancellationToken); + var boundaryInternal = RestClient.GetPolygon(coordinates, localizedMapView, options?.ResultType, options?.Resolution, options?.AcceptLanguage, cancellationToken); return Response.FromValue(new Boundary(boundaryInternal.Value), boundaryInternal.GetRawResponse()); } catch (Exception e) @@ -355,7 +355,7 @@ public virtual async Task> GetReverseGeocodingAsync( coordinatesList = new[] { coordinates.Longitude, coordinates.Latitude }; } - return await RestClient.GetReverseGeocodingAsync(coordinatesList, options?.ResultTypes, localizedMapView, cancellationToken).ConfigureAwait(false); + return await RestClient.GetReverseGeocodingAsync(coordinatesList, options?.ResultTypes, localizedMapView, options?.AcceptLanguage, cancellationToken).ConfigureAwait(false); } catch (Exception e) { @@ -390,7 +390,7 @@ public virtual Response GetReverseGeocoding(GeoPosition coord { coordinatesList = new[] { coordinates.Longitude, coordinates.Latitude }; } - return RestClient.GetReverseGeocoding(coordinatesList, options?.ResultTypes, localizedMapView, cancellationToken); + return RestClient.GetReverseGeocoding(coordinatesList, options?.ResultTypes, localizedMapView, options?.AcceptLanguage, cancellationToken); } catch (Exception e) { diff --git a/sdk/maps/Azure.Maps.Search/src/Models/GeocodingQuery.cs b/sdk/maps/Azure.Maps.Search/src/Models/GeocodingQuery.cs index 4936e1e4b4b3..58b297c6fef2 100644 --- a/sdk/maps/Azure.Maps.Search/src/Models/GeocodingQuery.cs +++ b/sdk/maps/Azure.Maps.Search/src/Models/GeocodingQuery.cs @@ -46,5 +46,11 @@ public class GeocodingQuery /// A point on the earth specified as a longitude and latitude. When you specify this parameter, the user’s location is taken into account and the results returned may be more relevant to the user. Example: GeoPosition(lon, lat) public GeoPosition? Coordinates { get; set; } + + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// + public string AcceptLanguage { get; set; } } } diff --git a/sdk/maps/Azure.Maps.Search/src/Models/GetPolygonOptions.cs b/sdk/maps/Azure.Maps.Search/src/Models/GetPolygonOptions.cs index 2af90eee1203..b5d01e733edd 100644 --- a/sdk/maps/Azure.Maps.Search/src/Models/GetPolygonOptions.cs +++ b/sdk/maps/Azure.Maps.Search/src/Models/GetPolygonOptions.cs @@ -19,5 +19,10 @@ public class GetPolygonOptions /// A point on the earth specified as a longitude and latitude. Example: GeoPosition(lon, lat) public GeoPosition Coordinates { get; set; } + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// + public string AcceptLanguage { get; set; } } } diff --git a/sdk/maps/Azure.Maps.Search/src/Models/ReverseGeocodingQuery.cs b/sdk/maps/Azure.Maps.Search/src/Models/ReverseGeocodingQuery.cs index 2d6420cc97cb..8ca9491b31bf 100644 --- a/sdk/maps/Azure.Maps.Search/src/Models/ReverseGeocodingQuery.cs +++ b/sdk/maps/Azure.Maps.Search/src/Models/ReverseGeocodingQuery.cs @@ -35,5 +35,11 @@ public class ReverseGeocodingQuery /// id of the request which would show in corresponding batchItem. public string OptionalId { get; set; } + + /// + /// Language in which search results should be returned. + /// Please refer to [Supported Languages](/azure/azure-maps/supported-languages) for details. + /// + public string AcceptLanguage { get; set; } } }