From 58f5f6912fd8fb0d5561147b7998509d9f6d60f6 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 9 May 2018 19:53:31 -0700 Subject: [PATCH] [AutoPR cognitiveservices/data-plane/CustomImageSearch] Adding custom image search swagger spec (#1765) (#1817) * Generated from c9d4d41fb69f65f205c2ecbcdde8d1d1262ecbb7 Adding custom image search * Generated from 9f5bcc92bfd5f05be333758d433ffa36c96e40a2 Adding custom image search * Generated from e8d819e50515f9b0ba463341a2a38b3a9ebc6210 Adding custom image search --- .../customimagesearch/models.go | 231 ++ .../v1.0/customimagesearch/client.go | 50 + .../v1.0/customimagesearch/custominstance.go | 403 ++ .../v1.0/customimagesearch/models.go | 3428 +++++++++++++++++ .../v1.0/customimagesearch/version.go | 30 + 5 files changed, 4142 insertions(+) create mode 100644 profiles/preview/cognitiveservices/customimagesearch/models.go create mode 100644 services/cognitiveservices/v1.0/customimagesearch/client.go create mode 100644 services/cognitiveservices/v1.0/customimagesearch/custominstance.go create mode 100644 services/cognitiveservices/v1.0/customimagesearch/models.go create mode 100644 services/cognitiveservices/v1.0/customimagesearch/version.go diff --git a/profiles/preview/cognitiveservices/customimagesearch/models.go b/profiles/preview/cognitiveservices/customimagesearch/models.go new file mode 100644 index 000000000000..87f3d9c48d37 --- /dev/null +++ b/profiles/preview/cognitiveservices/customimagesearch/models.go @@ -0,0 +1,231 @@ +// +build go1.9 + +// Copyright 2018 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package customimagesearch + +import original "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/customimagesearch" + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type BaseClient = original.BaseClient +type CustomInstanceClient = original.CustomInstanceClient +type ErrorCode = original.ErrorCode + +const ( + InsufficientAuthorization ErrorCode = original.InsufficientAuthorization + InvalidAuthorization ErrorCode = original.InvalidAuthorization + InvalidRequest ErrorCode = original.InvalidRequest + None ErrorCode = original.None + RateLimitExceeded ErrorCode = original.RateLimitExceeded + ServerError ErrorCode = original.ServerError +) + +type ErrorSubCode = original.ErrorSubCode + +const ( + AuthorizationDisabled ErrorSubCode = original.AuthorizationDisabled + AuthorizationExpired ErrorSubCode = original.AuthorizationExpired + AuthorizationMissing ErrorSubCode = original.AuthorizationMissing + AuthorizationRedundancy ErrorSubCode = original.AuthorizationRedundancy + Blocked ErrorSubCode = original.Blocked + HTTPNotAllowed ErrorSubCode = original.HTTPNotAllowed + NotImplemented ErrorSubCode = original.NotImplemented + ParameterInvalidValue ErrorSubCode = original.ParameterInvalidValue + ParameterMissing ErrorSubCode = original.ParameterMissing + ResourceError ErrorSubCode = original.ResourceError + UnexpectedError ErrorSubCode = original.UnexpectedError +) + +type Freshness = original.Freshness + +const ( + Day Freshness = original.Day + Month Freshness = original.Month + Week Freshness = original.Week +) + +type ImageAspect = original.ImageAspect + +const ( + All ImageAspect = original.All + Square ImageAspect = original.Square + Tall ImageAspect = original.Tall + Wide ImageAspect = original.Wide +) + +type ImageColor = original.ImageColor + +const ( + Black ImageColor = original.Black + Blue ImageColor = original.Blue + Brown ImageColor = original.Brown + ColorOnly ImageColor = original.ColorOnly + Gray ImageColor = original.Gray + Green ImageColor = original.Green + Monochrome ImageColor = original.Monochrome + Orange ImageColor = original.Orange + Pink ImageColor = original.Pink + Purple ImageColor = original.Purple + Red ImageColor = original.Red + Teal ImageColor = original.Teal + White ImageColor = original.White + Yellow ImageColor = original.Yellow +) + +type ImageContent = original.ImageContent + +const ( + Face ImageContent = original.Face + Portrait ImageContent = original.Portrait +) + +type ImageLicense = original.ImageLicense + +const ( + ImageLicenseAll ImageLicense = original.ImageLicenseAll + ImageLicenseAny ImageLicense = original.ImageLicenseAny + ImageLicenseModify ImageLicense = original.ImageLicenseModify + ImageLicenseModifyCommercially ImageLicense = original.ImageLicenseModifyCommercially + ImageLicensePublic ImageLicense = original.ImageLicensePublic + ImageLicenseShare ImageLicense = original.ImageLicenseShare + ImageLicenseShareCommercially ImageLicense = original.ImageLicenseShareCommercially +) + +type ImageSize = original.ImageSize + +const ( + ImageSizeAll ImageSize = original.ImageSizeAll + ImageSizeLarge ImageSize = original.ImageSizeLarge + ImageSizeMedium ImageSize = original.ImageSizeMedium + ImageSizeSmall ImageSize = original.ImageSizeSmall + ImageSizeWallpaper ImageSize = original.ImageSizeWallpaper +) + +type ImageType = original.ImageType + +const ( + AnimatedGif ImageType = original.AnimatedGif + Clipart ImageType = original.Clipart + Line ImageType = original.Line + Photo ImageType = original.Photo + Shopping ImageType = original.Shopping + Transparent ImageType = original.Transparent +) + +type SafeSearch = original.SafeSearch + +const ( + Moderate SafeSearch = original.Moderate + Off SafeSearch = original.Off + Strict SafeSearch = original.Strict +) + +type Type = original.Type + +const ( + TypeAnswer Type = original.TypeAnswer + TypeCreativeWork Type = original.TypeCreativeWork + TypeErrorResponse Type = original.TypeErrorResponse + TypeIdentifiable Type = original.TypeIdentifiable + TypeImageObject Type = original.TypeImageObject + TypeImages Type = original.TypeImages + TypeMediaObject Type = original.TypeMediaObject + TypeResponse Type = original.TypeResponse + TypeResponseBase Type = original.TypeResponseBase + TypeSearchResultsAnswer Type = original.TypeSearchResultsAnswer + TypeThing Type = original.TypeThing + TypeWebPage Type = original.TypeWebPage +) + +type BasicAnswer = original.BasicAnswer +type Answer = original.Answer +type BasicCreativeWork = original.BasicCreativeWork +type CreativeWork = original.CreativeWork +type Error = original.Error +type ErrorResponse = original.ErrorResponse +type BasicIdentifiable = original.BasicIdentifiable +type Identifiable = original.Identifiable +type ImageObject = original.ImageObject +type Images = original.Images +type BasicMediaObject = original.BasicMediaObject +type MediaObject = original.MediaObject +type Query = original.Query +type BasicResponse = original.BasicResponse +type Response = original.Response +type BasicResponseBase = original.BasicResponseBase +type ResponseBase = original.ResponseBase +type BasicSearchResultsAnswer = original.BasicSearchResultsAnswer +type SearchResultsAnswer = original.SearchResultsAnswer +type BasicThing = original.BasicThing +type Thing = original.Thing +type WebPage = original.WebPage + +func New() BaseClient { + return original.New() +} +func NewWithBaseURI(baseURI string) BaseClient { + return original.NewWithBaseURI(baseURI) +} +func NewCustomInstanceClient() CustomInstanceClient { + return original.NewCustomInstanceClient() +} +func NewCustomInstanceClientWithBaseURI(baseURI string) CustomInstanceClient { + return original.NewCustomInstanceClientWithBaseURI(baseURI) +} +func PossibleErrorCodeValues() []ErrorCode { + return original.PossibleErrorCodeValues() +} +func PossibleErrorSubCodeValues() []ErrorSubCode { + return original.PossibleErrorSubCodeValues() +} +func PossibleFreshnessValues() []Freshness { + return original.PossibleFreshnessValues() +} +func PossibleImageAspectValues() []ImageAspect { + return original.PossibleImageAspectValues() +} +func PossibleImageColorValues() []ImageColor { + return original.PossibleImageColorValues() +} +func PossibleImageContentValues() []ImageContent { + return original.PossibleImageContentValues() +} +func PossibleImageLicenseValues() []ImageLicense { + return original.PossibleImageLicenseValues() +} +func PossibleImageSizeValues() []ImageSize { + return original.PossibleImageSizeValues() +} +func PossibleImageTypeValues() []ImageType { + return original.PossibleImageTypeValues() +} +func PossibleSafeSearchValues() []SafeSearch { + return original.PossibleSafeSearchValues() +} +func PossibleTypeValues() []Type { + return original.PossibleTypeValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/cognitiveservices/v1.0/customimagesearch/client.go b/services/cognitiveservices/v1.0/customimagesearch/client.go new file mode 100644 index 000000000000..77532ef4bd5e --- /dev/null +++ b/services/cognitiveservices/v1.0/customimagesearch/client.go @@ -0,0 +1,50 @@ +// Package customimagesearch implements the Azure ARM Customimagesearch service API version 1.0. +// +// The Bing Custom Image Search API lets you send an image search query to Bing and get back image search results +// customized to meet your custom search definition. +package customimagesearch + +// Copyright (c) Microsoft and contributors. 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. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License 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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Customimagesearch + DefaultBaseURI = "https://api.cognitive.microsoft.com/bingcustomsearch/v7.0" +) + +// BaseClient is the base client for Customimagesearch. +type BaseClient struct { + autorest.Client + BaseURI string +} + +// New creates an instance of the BaseClient client. +func New() BaseClient { + return NewWithBaseURI(DefaultBaseURI) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + } +} diff --git a/services/cognitiveservices/v1.0/customimagesearch/custominstance.go b/services/cognitiveservices/v1.0/customimagesearch/custominstance.go new file mode 100644 index 000000000000..852084113084 --- /dev/null +++ b/services/cognitiveservices/v1.0/customimagesearch/custominstance.go @@ -0,0 +1,403 @@ +package customimagesearch + +// Copyright (c) Microsoft and contributors. 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. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License 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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CustomInstanceClient is the the Bing Custom Image Search API lets you send an image search query to Bing and get +// back image search results customized to meet your custom search definition. +type CustomInstanceClient struct { + BaseClient +} + +// NewCustomInstanceClient creates an instance of the CustomInstanceClient client. +func NewCustomInstanceClient() CustomInstanceClient { + return NewCustomInstanceClientWithBaseURI(DefaultBaseURI) +} + +// NewCustomInstanceClientWithBaseURI creates an instance of the CustomInstanceClient client. +func NewCustomInstanceClientWithBaseURI(baseURI string) CustomInstanceClient { + return CustomInstanceClient{NewWithBaseURI(baseURI)} +} + +// ImageSearch sends the image search request. +// Parameters: +// customConfig - the identifier for the custom search configuration +// query - the user's search query term. The term cannot be empty. The term may contain [Bing Advanced +// Operators](http://msdn.microsoft.com/library/ff795620.aspx). For example, to limit images to a specific +// domain, use the [site:](http://msdn.microsoft.com/library/ff795613.aspx) operator. To help improve relevance +// of an insights query (see +// [insightsToken](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#insightstoken)), +// you should always include the user's query term. Use this parameter only with the Image Search API.Do not +// specify this parameter when calling the Trending Images API. +// acceptLanguage - a comma-delimited list of one or more languages to use for user interface strings. The list +// is in decreasing order of preference. For additional information, including expected format, see +// [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the +// [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) +// query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify +// the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query +// parameter. To determine the market to return results for, Bing uses the first supported language it finds +// from the list and combines it with the cc parameter value. If the list does not include a supported +// language, Bing finds the closest language and market that supports the request or it uses an aggregated or +// default market for the results. To determine the market that Bing used, see the BingAPIs-Market header. Use +// this header and the cc query parameter only if you specify multiple languages. Otherwise, use the +// [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) and +// [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#setlang) +// query parameters. A user interface string is a string that's used as a label in a user interface. There are +// few user interface strings in the JSON response objects. Any links to Bing.com properties in the response +// objects apply the specified language. +// userAgent - the user agent originating the request. Bing uses the user agent to provide mobile users with an +// optimized experience. Although optional, you are encouraged to always specify this header. The user-agent +// should be the same string that any commonly used browser sends. For information about user agents, see [RFC +// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following are examples of user-agent +// strings. Windows Phone: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; +// ARM; Touch; NOKIA; Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - I500 Build / +// GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / 4.0 Mobile Safari / 533.1. iPhone: Mozilla / +// 5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 +// iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; WOW64; Trident / 7.0; Touch; +// rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, +// like Gecko) Version / 7.0 Mobile / 11A465 Safari / 9537.53 +// clientID - bing uses this header to provide users with consistent behavior across Bing API calls. Bing often +// flights new features and improvements, and it uses the client ID as a key for assigning traffic on different +// flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the +// user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an +// inconsistent user experience. For example, if the second request has a different flight assignment than the +// first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that +// client ID’s search history, providing a richer experience for the user. Bing also uses this header to help +// improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help +// with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the +// API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client +// ID across multiple requests for the same end user and device combination enables 1) the API consumer to +// receive a consistent user experience, and 2) higher click-through rates via better quality of results from +// the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client +// ID. If you do not include this header in the request, Bing generates an ID and returns it in the +// X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the +// first time the user uses your app on that device. Use the client ID for each Bing API request that your app +// makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a +// persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other +// apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses +// your app on that device, get the client ID that you persisted. Bing responses may or may not include this +// header. If the response includes this header, capture the client ID and use it for all subsequent Bing +// requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in +// the request. +// clientIP - the IPv4 or IPv6 address of the client device. The IP address is used to discover the user's +// location. Bing uses the location information to determine safe search behavior. Although optional, you are +// encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for +// example, by changing the last octet to 0). Obfuscating the address results in the location not being +// anywhere near the device's actual location, which may result in Bing serving erroneous results. +// location - a semicolon-delimited list of key/value pairs that describe the client's geographical location. +// Bing uses the location information to determine safe search behavior and to return relevant local content. +// Specify the key/value pair as :. The following are the keys that you use to specify the user's +// location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater +// than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and +// positive values indicate northern latitudes. long (required): The longitude of the client's location, in +// degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative +// values indicate western longitudes and positive values indicate eastern longitudes. re (required): The +// radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by +// the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, +// and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the +// location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's +// relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, +// counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): +// The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): +// The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the +// vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the +// keys are optional, the more information that you provide, the more accurate the location results are. +// Although optional, you are encouraged to always specify the user's geographical location. Providing the +// location is especially important if the client's IP address does not accurately reflect the user's physical +// location (for example, if the client uses VPN). For optimal results, you should include this header and the +// X-MSEdge-ClientIP header, but at a minimum, you should include this header. +// aspect - filter images by the following aspect ratios. All: Do not filter by aspect.Specifying this value is +// the same as not specifying the aspect parameter. Square: Return images with standard aspect ratio. Wide: +// Return images with wide screen aspect ratio. Tall: Return images with tall aspect ratio. +// colorParameter - filter images by the following color options. ColorOnly: Return color images. Monochrome: +// Return black and white images. Return images with one of the following dominant colors: Black, Blue, Brown, +// Gray, Green, Orange, Pink, Purple, Red, Teal, White, Yellow +// countryCode - a 2-character country code of the country where the results come from. For a list of possible +// values, see [Market +// Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). +// If you set this parameter, you must also specify the +// [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) +// header. Bing uses the first supported language it finds from the languages list, and combine that language +// with the country code that you specify to determine the market to return results for. If the languages list +// does not include a supported language, Bing finds the closest language and market that supports the request, +// or it may use an aggregated or default market for the results instead of a specified one. You should use +// this query parameter and the Accept-Language query parameter only if you specify multiple languages; +// otherwise, you should use the mkt and setLang query parameters. This parameter and the +// [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#mkt) query +// parameter are mutually exclusive—do not specify both. +// count - the number of images to return in the response. The actual number delivered may be less than +// requested. The default is 35. The maximum value is 150. You use this parameter along with the offset +// parameter to page results.For example, if your user interface displays 20 images per page, set count to 20 +// and offset to 0 to get the first page of results.For each subsequent page, increment offset by 20 (for +// example, 0, 20, 40). Use this parameter only with the Image Search API.Do not specify this parameter when +// calling the Insights, Trending Images, or Web Search APIs. +// freshness - filter images by the following discovery options. Day: Return images discovered by Bing within +// the last 24 hours. Week: Return images discovered by Bing within the last 7 days. Month: Return images +// discovered by Bing within the last 30 days. +// height - filter images that have the specified height, in pixels. You may use this filter with the size +// filter to return small images that have a height of 150 pixels. +// ID - an ID that uniquely identifies an image. Use this parameter to ensure that the specified image is the +// first image in the list of images that Bing returns. The +// [Image](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#image) +// object's imageId field contains the ID that you set this parameter to. +// imageContent - filter images by the following content types. Face: Return images that show only a person's +// face. Portrait: Return images that show only a person's head and shoulders. +// imageType - filter images by the following image types. AnimatedGif: Return only animated GIFs. Clipart: +// Return only clip art images. Line: Return only line drawings. Photo: Return only photographs(excluding line +// drawings, animated Gifs, and clip art). Shopping: Return only images that contain items where Bing knows of +// a merchant that is selling the items. This option is valid in the en - US market only.Transparent: Return +// only images with a transparent background. +// license - filter images by the following license types. All: Do not filter by license type.Specifying this +// value is the same as not specifying the license parameter. Any: Return images that are under any license +// type. The response doesn't include images that do not specify a license or the license is unknown. Public: +// Return images where the creator has waived their exclusive rights, to the fullest extent allowed by law. +// Share: Return images that may be shared with others. Changing or editing the image might not be allowed. +// Also, modifying, sharing, and using the image for commercial purposes might not be allowed. Typically, this +// option returns the most images. ShareCommercially: Return images that may be shared with others for personal +// or commercial purposes. Changing or editing the image might not be allowed. Modify: Return images that may +// be modified, shared, and used. Changing or editing the image might not be allowed. Modifying, sharing, and +// using the image for commercial purposes might not be allowed. ModifyCommercially: Return images that may be +// modified, shared, and used for personal or commercial purposes. Typically, this option returns the fewest +// images. For more information about these license types, see [Filter Images By License +// Type](http://go.microsoft.com/fwlink/?LinkId=309768). +// market - the market where the results come from. Typically, mkt is the country where the user is making the +// request from. However, it could be a different country if the user is not located in a country where Bing +// delivers results. The market must be in the form -. For example, en-US. The +// string is case insensitive. For a list of possible market values, see [Market +// Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes). +// NOTE: If known, you are encouraged to always specify the market. Specifying the market helps Bing route the +// request and return an appropriate and optimal response. If you specify a market that is not listed in +// [Market +// Codes](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#market-codes), +// Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and +// the [cc](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#cc) query +// parameter are mutually exclusive—do not specify both. +// maxFileSize - filter images that are less than or equal to the specified file size. The maximum file size +// that you may specify is 520,192 bytes. If you specify a larger value, the API uses 520,192. It is possible +// that the response may include images that are slightly larger than the specified maximum. You may specify +// this filter and minFileSize to filter images within a range of file sizes. +// maxHeight - filter images that have a height that is less than or equal to the specified height. Specify the +// height in pixels. You may specify this filter and minHeight to filter images within a range of heights. This +// filter and the height filter are mutually exclusive. +// maxWidth - filter images that have a width that is less than or equal to the specified width. Specify the +// width in pixels. You may specify this filter and maxWidth to filter images within a range of widths. This +// filter and the width filter are mutually exclusive. +// minFileSize - filter images that are greater than or equal to the specified file size. The maximum file size +// that you may specify is 520,192 bytes. If you specify a larger value, the API uses 520,192. It is possible +// that the response may include images that are slightly smaller than the specified minimum. You may specify +// this filter and maxFileSize to filter images within a range of file sizes. +// minHeight - filter images that have a height that is greater than or equal to the specified height. Specify +// the height in pixels. You may specify this filter and maxHeight to filter images within a range of heights. +// This filter and the height filter are mutually exclusive. +// minWidth - filter images that have a width that is greater than or equal to the specified width. Specify the +// width in pixels. You may specify this filter and maxWidth to filter images within a range of widths. This +// filter and the width filter are mutually exclusive. +// offset - the zero-based offset that indicates the number of images to skip before returning images. The +// default is 0. The offset should be less than +// ([totalEstimatedMatches](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#totalestimatedmatches) +// - count). Use this parameter along with the count parameter to page results. For example, if your user +// interface displays 20 images per page, set count to 20 and offset to 0 to get the first page of results. For +// each subsequent page, increment offset by 20 (for example, 0, 20, 40). It is possible for multiple pages to +// include some overlap in results. To prevent duplicates, see +// [nextOffset](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#nextoffset). +// Use this parameter only with the Image API. Do not specify this parameter when calling the Trending Images +// API or the Web Search API. +// safeSearch - filter images for adult content. The following are the possible filter values. Off: May return +// images with adult content. If the request is through the Image Search API, the response includes thumbnail +// images that are clear (non-fuzzy). However, if the request is through the Web Search API, the response +// includes thumbnail images that are pixelated (fuzzy). Moderate: If the request is through the Image Search +// API, the response doesn't include images with adult content. If the request is through the Web Search API, +// the response may include images with adult content (the thumbnail images are pixelated (fuzzy)). Strict: Do +// not return images with adult content. The default is Moderate. If the request comes from a market that +// Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses +// Strict. If you use the site: query operator, there is the chance that the response may contain adult content +// regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content +// on the site and your scenario supports the possibility of adult content. +// size - filter images by the following sizes. All: Do not filter by size. Specifying this value is the same +// as not specifying the size parameter. Small: Return images that are less than 200x200 pixels. Medium: Return +// images that are greater than or equal to 200x200 pixels but less than 500x500 pixels. Large: Return images +// that are 500x500 pixels or larger. Wallpaper: Return wallpaper images. You may use this parameter along with +// the height or width parameters. For example, you may use height and size to request small images that are +// 150 pixels tall. +// setLang - the language to use for user interface strings. Specify the language using the ISO 639-1 2-letter +// language code. For example, the language code for English is EN. The default is EN (English). Although +// optional, you should always specify the language. Typically, you set setLang to the same language specified +// by mkt unless the user wants the user interface strings displayed in a different language. This parameter +// and the +// [Accept-Language](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-reference#acceptlanguage) +// header are mutually exclusive; do not specify both. A user interface string is a string that's used as a +// label in a user interface. There are few user interface strings in the JSON response objects. Also, any +// links to Bing.com properties in the response objects apply the specified language. +// width - filter images that have the specified width, in pixels. You may use this filter with the size filter +// to return small images that have a width of 150 pixels. +func (client CustomInstanceClient) ImageSearch(ctx context.Context, customConfig int64, query string, acceptLanguage string, userAgent string, clientID string, clientIP string, location string, aspect ImageAspect, colorParameter ImageColor, countryCode string, count *int32, freshness Freshness, height *int32, ID string, imageContent ImageContent, imageType ImageType, license ImageLicense, market string, maxFileSize *int64, maxHeight *int64, maxWidth *int64, minFileSize *int64, minHeight *int64, minWidth *int64, offset *int64, safeSearch SafeSearch, size ImageSize, setLang string, width *int32) (result Images, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: customConfig, + Constraints: []validation.Constraint{{Target: "customConfig", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}); err != nil { + return result, validation.NewError("customimagesearch.CustomInstanceClient", "ImageSearch", err.Error()) + } + + req, err := client.ImageSearchPreparer(ctx, customConfig, query, acceptLanguage, userAgent, clientID, clientIP, location, aspect, colorParameter, countryCode, count, freshness, height, ID, imageContent, imageType, license, market, maxFileSize, maxHeight, maxWidth, minFileSize, minHeight, minWidth, offset, safeSearch, size, setLang, width) + if err != nil { + err = autorest.NewErrorWithError(err, "customimagesearch.CustomInstanceClient", "ImageSearch", nil, "Failure preparing request") + return + } + + resp, err := client.ImageSearchSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "customimagesearch.CustomInstanceClient", "ImageSearch", resp, "Failure sending request") + return + } + + result, err = client.ImageSearchResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "customimagesearch.CustomInstanceClient", "ImageSearch", resp, "Failure responding to request") + } + + return +} + +// ImageSearchPreparer prepares the ImageSearch request. +func (client CustomInstanceClient) ImageSearchPreparer(ctx context.Context, customConfig int64, query string, acceptLanguage string, userAgent string, clientID string, clientIP string, location string, aspect ImageAspect, colorParameter ImageColor, countryCode string, count *int32, freshness Freshness, height *int32, ID string, imageContent ImageContent, imageType ImageType, license ImageLicense, market string, maxFileSize *int64, maxHeight *int64, maxWidth *int64, minFileSize *int64, minHeight *int64, minWidth *int64, offset *int64, safeSearch SafeSearch, size ImageSize, setLang string, width *int32) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "customConfig": autorest.Encode("query", customConfig), + "q": autorest.Encode("query", query), + } + if len(string(aspect)) > 0 { + queryParameters["aspect"] = autorest.Encode("query", aspect) + } + if len(string(colorParameter)) > 0 { + queryParameters["color"] = autorest.Encode("query", colorParameter) + } + if len(countryCode) > 0 { + queryParameters["cc"] = autorest.Encode("query", countryCode) + } + if count != nil { + queryParameters["count"] = autorest.Encode("query", *count) + } + if len(string(freshness)) > 0 { + queryParameters["freshness"] = autorest.Encode("query", freshness) + } + if height != nil { + queryParameters["height"] = autorest.Encode("query", *height) + } + if len(ID) > 0 { + queryParameters["id"] = autorest.Encode("query", ID) + } + if len(string(imageContent)) > 0 { + queryParameters["imageContent"] = autorest.Encode("query", imageContent) + } + if len(string(imageType)) > 0 { + queryParameters["imageType"] = autorest.Encode("query", imageType) + } + if len(string(license)) > 0 { + queryParameters["license"] = autorest.Encode("query", license) + } + if len(market) > 0 { + queryParameters["mkt"] = autorest.Encode("query", market) + } + if maxFileSize != nil { + queryParameters["maxFileSize"] = autorest.Encode("query", *maxFileSize) + } + if maxHeight != nil { + queryParameters["maxHeight"] = autorest.Encode("query", *maxHeight) + } + if maxWidth != nil { + queryParameters["maxWidth"] = autorest.Encode("query", *maxWidth) + } + if minFileSize != nil { + queryParameters["minFileSize"] = autorest.Encode("query", *minFileSize) + } + if minHeight != nil { + queryParameters["minHeight"] = autorest.Encode("query", *minHeight) + } + if minWidth != nil { + queryParameters["minWidth"] = autorest.Encode("query", *minWidth) + } + if offset != nil { + queryParameters["offset"] = autorest.Encode("query", *offset) + } + if len(string(safeSearch)) > 0 { + queryParameters["safeSearch"] = autorest.Encode("query", safeSearch) + } + if len(string(size)) > 0 { + queryParameters["size"] = autorest.Encode("query", size) + } + if len(setLang) > 0 { + queryParameters["setLang"] = autorest.Encode("query", setLang) + } + if width != nil { + queryParameters["width"] = autorest.Encode("query", *width) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/images/search"), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("X-BingApis-SDK", "true")) + if len(acceptLanguage) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("Accept-Language", autorest.String(acceptLanguage))) + } + if len(userAgent) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("User-Agent", autorest.String(userAgent))) + } + if len(clientID) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("X-MSEdge-ClientID", autorest.String(clientID))) + } + if len(clientIP) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("X-MSEdge-ClientIP", autorest.String(clientIP))) + } + if len(location) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("X-Search-Location", autorest.String(location))) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ImageSearchSender sends the ImageSearch request. The method will close the +// http.Response Body if it receives an error. +func (client CustomInstanceClient) ImageSearchSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ImageSearchResponder handles the response to the ImageSearch request. The method always +// closes the http.Response Body. +func (client CustomInstanceClient) ImageSearchResponder(resp *http.Response) (result Images, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/cognitiveservices/v1.0/customimagesearch/models.go b/services/cognitiveservices/v1.0/customimagesearch/models.go new file mode 100644 index 000000000000..b758c2240636 --- /dev/null +++ b/services/cognitiveservices/v1.0/customimagesearch/models.go @@ -0,0 +1,3428 @@ +package customimagesearch + +// Copyright (c) Microsoft and contributors. 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. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License 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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" +) + +// ErrorCode enumerates the values for error code. +type ErrorCode string + +const ( + // InsufficientAuthorization ... + InsufficientAuthorization ErrorCode = "InsufficientAuthorization" + // InvalidAuthorization ... + InvalidAuthorization ErrorCode = "InvalidAuthorization" + // InvalidRequest ... + InvalidRequest ErrorCode = "InvalidRequest" + // None ... + None ErrorCode = "None" + // RateLimitExceeded ... + RateLimitExceeded ErrorCode = "RateLimitExceeded" + // ServerError ... + ServerError ErrorCode = "ServerError" +) + +// PossibleErrorCodeValues returns an array of possible values for the ErrorCode const type. +func PossibleErrorCodeValues() []ErrorCode { + return []ErrorCode{InsufficientAuthorization, InvalidAuthorization, InvalidRequest, None, RateLimitExceeded, ServerError} +} + +// ErrorSubCode enumerates the values for error sub code. +type ErrorSubCode string + +const ( + // AuthorizationDisabled ... + AuthorizationDisabled ErrorSubCode = "AuthorizationDisabled" + // AuthorizationExpired ... + AuthorizationExpired ErrorSubCode = "AuthorizationExpired" + // AuthorizationMissing ... + AuthorizationMissing ErrorSubCode = "AuthorizationMissing" + // AuthorizationRedundancy ... + AuthorizationRedundancy ErrorSubCode = "AuthorizationRedundancy" + // Blocked ... + Blocked ErrorSubCode = "Blocked" + // HTTPNotAllowed ... + HTTPNotAllowed ErrorSubCode = "HttpNotAllowed" + // NotImplemented ... + NotImplemented ErrorSubCode = "NotImplemented" + // ParameterInvalidValue ... + ParameterInvalidValue ErrorSubCode = "ParameterInvalidValue" + // ParameterMissing ... + ParameterMissing ErrorSubCode = "ParameterMissing" + // ResourceError ... + ResourceError ErrorSubCode = "ResourceError" + // UnexpectedError ... + UnexpectedError ErrorSubCode = "UnexpectedError" +) + +// PossibleErrorSubCodeValues returns an array of possible values for the ErrorSubCode const type. +func PossibleErrorSubCodeValues() []ErrorSubCode { + return []ErrorSubCode{AuthorizationDisabled, AuthorizationExpired, AuthorizationMissing, AuthorizationRedundancy, Blocked, HTTPNotAllowed, NotImplemented, ParameterInvalidValue, ParameterMissing, ResourceError, UnexpectedError} +} + +// Freshness enumerates the values for freshness. +type Freshness string + +const ( + // Day ... + Day Freshness = "Day" + // Month ... + Month Freshness = "Month" + // Week ... + Week Freshness = "Week" +) + +// PossibleFreshnessValues returns an array of possible values for the Freshness const type. +func PossibleFreshnessValues() []Freshness { + return []Freshness{Day, Month, Week} +} + +// ImageAspect enumerates the values for image aspect. +type ImageAspect string + +const ( + // All ... + All ImageAspect = "All" + // Square ... + Square ImageAspect = "Square" + // Tall ... + Tall ImageAspect = "Tall" + // Wide ... + Wide ImageAspect = "Wide" +) + +// PossibleImageAspectValues returns an array of possible values for the ImageAspect const type. +func PossibleImageAspectValues() []ImageAspect { + return []ImageAspect{All, Square, Tall, Wide} +} + +// ImageColor enumerates the values for image color. +type ImageColor string + +const ( + // Black ... + Black ImageColor = "Black" + // Blue ... + Blue ImageColor = "Blue" + // Brown ... + Brown ImageColor = "Brown" + // ColorOnly ... + ColorOnly ImageColor = "ColorOnly" + // Gray ... + Gray ImageColor = "Gray" + // Green ... + Green ImageColor = "Green" + // Monochrome ... + Monochrome ImageColor = "Monochrome" + // Orange ... + Orange ImageColor = "Orange" + // Pink ... + Pink ImageColor = "Pink" + // Purple ... + Purple ImageColor = "Purple" + // Red ... + Red ImageColor = "Red" + // Teal ... + Teal ImageColor = "Teal" + // White ... + White ImageColor = "White" + // Yellow ... + Yellow ImageColor = "Yellow" +) + +// PossibleImageColorValues returns an array of possible values for the ImageColor const type. +func PossibleImageColorValues() []ImageColor { + return []ImageColor{Black, Blue, Brown, ColorOnly, Gray, Green, Monochrome, Orange, Pink, Purple, Red, Teal, White, Yellow} +} + +// ImageContent enumerates the values for image content. +type ImageContent string + +const ( + // Face ... + Face ImageContent = "Face" + // Portrait ... + Portrait ImageContent = "Portrait" +) + +// PossibleImageContentValues returns an array of possible values for the ImageContent const type. +func PossibleImageContentValues() []ImageContent { + return []ImageContent{Face, Portrait} +} + +// ImageLicense enumerates the values for image license. +type ImageLicense string + +const ( + // ImageLicenseAll ... + ImageLicenseAll ImageLicense = "All" + // ImageLicenseAny ... + ImageLicenseAny ImageLicense = "Any" + // ImageLicenseModify ... + ImageLicenseModify ImageLicense = "Modify" + // ImageLicenseModifyCommercially ... + ImageLicenseModifyCommercially ImageLicense = "ModifyCommercially" + // ImageLicensePublic ... + ImageLicensePublic ImageLicense = "Public" + // ImageLicenseShare ... + ImageLicenseShare ImageLicense = "Share" + // ImageLicenseShareCommercially ... + ImageLicenseShareCommercially ImageLicense = "ShareCommercially" +) + +// PossibleImageLicenseValues returns an array of possible values for the ImageLicense const type. +func PossibleImageLicenseValues() []ImageLicense { + return []ImageLicense{ImageLicenseAll, ImageLicenseAny, ImageLicenseModify, ImageLicenseModifyCommercially, ImageLicensePublic, ImageLicenseShare, ImageLicenseShareCommercially} +} + +// ImageSize enumerates the values for image size. +type ImageSize string + +const ( + // ImageSizeAll ... + ImageSizeAll ImageSize = "All" + // ImageSizeLarge ... + ImageSizeLarge ImageSize = "Large" + // ImageSizeMedium ... + ImageSizeMedium ImageSize = "Medium" + // ImageSizeSmall ... + ImageSizeSmall ImageSize = "Small" + // ImageSizeWallpaper ... + ImageSizeWallpaper ImageSize = "Wallpaper" +) + +// PossibleImageSizeValues returns an array of possible values for the ImageSize const type. +func PossibleImageSizeValues() []ImageSize { + return []ImageSize{ImageSizeAll, ImageSizeLarge, ImageSizeMedium, ImageSizeSmall, ImageSizeWallpaper} +} + +// ImageType enumerates the values for image type. +type ImageType string + +const ( + // AnimatedGif ... + AnimatedGif ImageType = "AnimatedGif" + // Clipart ... + Clipart ImageType = "Clipart" + // Line ... + Line ImageType = "Line" + // Photo ... + Photo ImageType = "Photo" + // Shopping ... + Shopping ImageType = "Shopping" + // Transparent ... + Transparent ImageType = "Transparent" +) + +// PossibleImageTypeValues returns an array of possible values for the ImageType const type. +func PossibleImageTypeValues() []ImageType { + return []ImageType{AnimatedGif, Clipart, Line, Photo, Shopping, Transparent} +} + +// SafeSearch enumerates the values for safe search. +type SafeSearch string + +const ( + // Moderate ... + Moderate SafeSearch = "Moderate" + // Off ... + Off SafeSearch = "Off" + // Strict ... + Strict SafeSearch = "Strict" +) + +// PossibleSafeSearchValues returns an array of possible values for the SafeSearch const type. +func PossibleSafeSearchValues() []SafeSearch { + return []SafeSearch{Moderate, Off, Strict} +} + +// Type enumerates the values for type. +type Type string + +const ( + // TypeAnswer ... + TypeAnswer Type = "Answer" + // TypeCreativeWork ... + TypeCreativeWork Type = "CreativeWork" + // TypeErrorResponse ... + TypeErrorResponse Type = "ErrorResponse" + // TypeIdentifiable ... + TypeIdentifiable Type = "Identifiable" + // TypeImageObject ... + TypeImageObject Type = "ImageObject" + // TypeImages ... + TypeImages Type = "Images" + // TypeMediaObject ... + TypeMediaObject Type = "MediaObject" + // TypeResponse ... + TypeResponse Type = "Response" + // TypeResponseBase ... + TypeResponseBase Type = "ResponseBase" + // TypeSearchResultsAnswer ... + TypeSearchResultsAnswer Type = "SearchResultsAnswer" + // TypeThing ... + TypeThing Type = "Thing" + // TypeWebPage ... + TypeWebPage Type = "WebPage" +) + +// PossibleTypeValues returns an array of possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{TypeAnswer, TypeCreativeWork, TypeErrorResponse, TypeIdentifiable, TypeImageObject, TypeImages, TypeMediaObject, TypeResponse, TypeResponseBase, TypeSearchResultsAnswer, TypeThing, TypeWebPage} +} + +// BasicAnswer defines an answer. +type BasicAnswer interface { + AsImages() (*Images, bool) + AsSearchResultsAnswer() (*SearchResultsAnswer, bool) + AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) + AsAnswer() (*Answer, bool) +} + +// Answer defines an answer. +type Answer struct { + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicAnswer(body []byte) (BasicAnswer, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImages): + var i Images + err := json.Unmarshal(body, &i) + return i, err + case string(TypeSearchResultsAnswer): + var sra SearchResultsAnswer + err := json.Unmarshal(body, &sra) + return sra, err + default: + var a Answer + err := json.Unmarshal(body, &a) + return a, err + } +} +func unmarshalBasicAnswerArray(body []byte) ([]BasicAnswer, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + aArray := make([]BasicAnswer, len(rawMessages)) + + for index, rawMessage := range rawMessages { + a, err := unmarshalBasicAnswer(*rawMessage) + if err != nil { + return nil, err + } + aArray[index] = a + } + return aArray, nil +} + +// MarshalJSON is the custom marshaler for Answer. +func (a Answer) MarshalJSON() ([]byte, error) { + a.Type = TypeAnswer + objectMap := make(map[string]interface{}) + if a.ReadLink != nil { + objectMap["readLink"] = a.ReadLink + } + if a.WebSearchURL != nil { + objectMap["webSearchUrl"] = a.WebSearchURL + } + if a.ID != nil { + objectMap["id"] = a.ID + } + if a.Type != "" { + objectMap["_type"] = a.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for Answer. +func (a Answer) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for Answer. +func (a Answer) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for Answer. +func (a Answer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for Answer. +func (a Answer) AsAnswer() (*Answer, bool) { + return &a, true +} + +// AsBasicAnswer is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicAnswer() (BasicAnswer, bool) { + return &a, true +} + +// AsMediaObject is the BasicResponseBase implementation for Answer. +func (a Answer) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for Answer. +func (a Answer) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicResponse() (BasicResponse, bool) { + return &a, true +} + +// AsThing is the BasicResponseBase implementation for Answer. +func (a Answer) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for Answer. +func (a Answer) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for Answer. +func (a Answer) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &a, true +} + +// AsErrorResponse is the BasicResponseBase implementation for Answer. +func (a Answer) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for Answer. +func (a Answer) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for Answer. +func (a Answer) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for Answer. +func (a Answer) AsBasicResponseBase() (BasicResponseBase, bool) { + return &a, true +} + +// BasicCreativeWork the most generic kind of creative work, including books, movies, photographs, software programs, +// etc. +type BasicCreativeWork interface { + AsImageObject() (*ImageObject, bool) + AsMediaObject() (*MediaObject, bool) + AsBasicMediaObject() (BasicMediaObject, bool) + AsWebPage() (*WebPage, bool) + AsCreativeWork() (*CreativeWork, bool) +} + +// CreativeWork the most generic kind of creative work, including books, movies, photographs, software programs, +// etc. +type CreativeWork struct { + // ThumbnailURL - The URL to a thumbnail of the item. + ThumbnailURL *string `json:"thumbnailUrl,omitempty"` + // Provider - The source of the creative work. + Provider *[]BasicThing `json:"provider,omitempty"` + // Text - Text content of this creative work + Text *string `json:"text,omitempty"` + // Name - The name of the thing represented by this object. + Name *string `json:"name,omitempty"` + // URL - The URL to get more information about the thing represented by this object. + URL *string `json:"url,omitempty"` + // Image - An image of the item. + Image *ImageObject `json:"image,omitempty"` + // Description - A short description of the item. + Description *string `json:"description,omitempty"` + // AlternateName - An alias for the item + AlternateName *string `json:"alternateName,omitempty"` + // BingID - An ID that uniquely identifies this item. + BingID *string `json:"bingId,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicCreativeWork(body []byte) (BasicCreativeWork, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImageObject): + var ioVar ImageObject + err := json.Unmarshal(body, &ioVar) + return ioVar, err + case string(TypeMediaObject): + var mo MediaObject + err := json.Unmarshal(body, &mo) + return mo, err + case string(TypeWebPage): + var wp WebPage + err := json.Unmarshal(body, &wp) + return wp, err + default: + var cw CreativeWork + err := json.Unmarshal(body, &cw) + return cw, err + } +} +func unmarshalBasicCreativeWorkArray(body []byte) ([]BasicCreativeWork, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + cwArray := make([]BasicCreativeWork, len(rawMessages)) + + for index, rawMessage := range rawMessages { + cw, err := unmarshalBasicCreativeWork(*rawMessage) + if err != nil { + return nil, err + } + cwArray[index] = cw + } + return cwArray, nil +} + +// MarshalJSON is the custom marshaler for CreativeWork. +func (cw CreativeWork) MarshalJSON() ([]byte, error) { + cw.Type = TypeCreativeWork + objectMap := make(map[string]interface{}) + if cw.ThumbnailURL != nil { + objectMap["thumbnailUrl"] = cw.ThumbnailURL + } + if cw.Provider != nil { + objectMap["provider"] = cw.Provider + } + if cw.Text != nil { + objectMap["text"] = cw.Text + } + if cw.Name != nil { + objectMap["name"] = cw.Name + } + if cw.URL != nil { + objectMap["url"] = cw.URL + } + if cw.Image != nil { + objectMap["image"] = cw.Image + } + if cw.Description != nil { + objectMap["description"] = cw.Description + } + if cw.AlternateName != nil { + objectMap["alternateName"] = cw.AlternateName + } + if cw.BingID != nil { + objectMap["bingId"] = cw.BingID + } + if cw.ReadLink != nil { + objectMap["readLink"] = cw.ReadLink + } + if cw.WebSearchURL != nil { + objectMap["webSearchUrl"] = cw.WebSearchURL + } + if cw.ID != nil { + objectMap["id"] = cw.ID + } + if cw.Type != "" { + objectMap["_type"] = cw.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicResponse() (BasicResponse, bool) { + return &cw, true +} + +// AsThing is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicThing() (BasicThing, bool) { + return &cw, true +} + +// AsCreativeWork is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsCreativeWork() (*CreativeWork, bool) { + return &cw, true +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return &cw, true +} + +// AsIdentifiable is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &cw, true +} + +// AsErrorResponse is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for CreativeWork. +func (cw CreativeWork) AsBasicResponseBase() (BasicResponseBase, bool) { + return &cw, true +} + +// UnmarshalJSON is the custom unmarshaler for CreativeWork struct. +func (cw *CreativeWork) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "thumbnailUrl": + if v != nil { + var thumbnailURL string + err = json.Unmarshal(*v, &thumbnailURL) + if err != nil { + return err + } + cw.ThumbnailURL = &thumbnailURL + } + case "provider": + if v != nil { + provider, err := unmarshalBasicThingArray(*v) + if err != nil { + return err + } + cw.Provider = &provider + } + case "text": + if v != nil { + var textVar string + err = json.Unmarshal(*v, &textVar) + if err != nil { + return err + } + cw.Text = &textVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cw.Name = &name + } + case "url": + if v != nil { + var URL string + err = json.Unmarshal(*v, &URL) + if err != nil { + return err + } + cw.URL = &URL + } + case "image": + if v != nil { + var imageVar ImageObject + err = json.Unmarshal(*v, &imageVar) + if err != nil { + return err + } + cw.Image = &imageVar + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + cw.Description = &description + } + case "alternateName": + if v != nil { + var alternateName string + err = json.Unmarshal(*v, &alternateName) + if err != nil { + return err + } + cw.AlternateName = &alternateName + } + case "bingId": + if v != nil { + var bingID string + err = json.Unmarshal(*v, &bingID) + if err != nil { + return err + } + cw.BingID = &bingID + } + case "readLink": + if v != nil { + var readLink string + err = json.Unmarshal(*v, &readLink) + if err != nil { + return err + } + cw.ReadLink = &readLink + } + case "webSearchUrl": + if v != nil { + var webSearchURL string + err = json.Unmarshal(*v, &webSearchURL) + if err != nil { + return err + } + cw.WebSearchURL = &webSearchURL + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cw.ID = &ID + } + case "_type": + if v != nil { + var typeVar Type + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cw.Type = typeVar + } + } + } + + return nil +} + +// Error defines the error that occurred. +type Error struct { + // Code - The error code that identifies the category of error. Possible values include: 'None', 'ServerError', 'InvalidRequest', 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization' + Code ErrorCode `json:"code,omitempty"` + // SubCode - The error code that further helps to identify the error. Possible values include: 'UnexpectedError', 'ResourceError', 'NotImplemented', 'ParameterMissing', 'ParameterInvalidValue', 'HTTPNotAllowed', 'Blocked', 'AuthorizationMissing', 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired' + SubCode ErrorSubCode `json:"subCode,omitempty"` + // Message - A description of the error. + Message *string `json:"message,omitempty"` + // MoreDetails - A description that provides additional information about the error. + MoreDetails *string `json:"moreDetails,omitempty"` + // Parameter - The parameter in the request that caused the error. + Parameter *string `json:"parameter,omitempty"` + // Value - The parameter's value in the request that was not valid. + Value *string `json:"value,omitempty"` +} + +// ErrorResponse the top-level response that represents a failed request. +type ErrorResponse struct { + // Errors - A list of errors that describe the reasons why the request failed. + Errors *[]Error `json:"errors,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorResponse. +func (er ErrorResponse) MarshalJSON() ([]byte, error) { + er.Type = TypeErrorResponse + objectMap := make(map[string]interface{}) + if er.Errors != nil { + objectMap["errors"] = er.Errors + } + if er.ReadLink != nil { + objectMap["readLink"] = er.ReadLink + } + if er.WebSearchURL != nil { + objectMap["webSearchUrl"] = er.WebSearchURL + } + if er.ID != nil { + objectMap["id"] = er.ID + } + if er.Type != "" { + objectMap["_type"] = er.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicResponse() (BasicResponse, bool) { + return &er, true +} + +// AsThing is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &er, true +} + +// AsErrorResponse is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsErrorResponse() (*ErrorResponse, bool) { + return &er, true +} + +// AsWebPage is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for ErrorResponse. +func (er ErrorResponse) AsBasicResponseBase() (BasicResponseBase, bool) { + return &er, true +} + +// BasicIdentifiable defines the identity of a resource. +type BasicIdentifiable interface { + AsImageObject() (*ImageObject, bool) + AsImages() (*Images, bool) + AsSearchResultsAnswer() (*SearchResultsAnswer, bool) + AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) + AsAnswer() (*Answer, bool) + AsBasicAnswer() (BasicAnswer, bool) + AsMediaObject() (*MediaObject, bool) + AsBasicMediaObject() (BasicMediaObject, bool) + AsResponse() (*Response, bool) + AsBasicResponse() (BasicResponse, bool) + AsThing() (*Thing, bool) + AsBasicThing() (BasicThing, bool) + AsCreativeWork() (*CreativeWork, bool) + AsBasicCreativeWork() (BasicCreativeWork, bool) + AsErrorResponse() (*ErrorResponse, bool) + AsWebPage() (*WebPage, bool) + AsIdentifiable() (*Identifiable, bool) +} + +// Identifiable defines the identity of a resource. +type Identifiable struct { + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicIdentifiable(body []byte) (BasicIdentifiable, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImageObject): + var ioVar ImageObject + err := json.Unmarshal(body, &ioVar) + return ioVar, err + case string(TypeImages): + var i Images + err := json.Unmarshal(body, &i) + return i, err + case string(TypeSearchResultsAnswer): + var sra SearchResultsAnswer + err := json.Unmarshal(body, &sra) + return sra, err + case string(TypeAnswer): + var a Answer + err := json.Unmarshal(body, &a) + return a, err + case string(TypeMediaObject): + var mo MediaObject + err := json.Unmarshal(body, &mo) + return mo, err + case string(TypeResponse): + var r Response + err := json.Unmarshal(body, &r) + return r, err + case string(TypeThing): + var t Thing + err := json.Unmarshal(body, &t) + return t, err + case string(TypeCreativeWork): + var cw CreativeWork + err := json.Unmarshal(body, &cw) + return cw, err + case string(TypeErrorResponse): + var er ErrorResponse + err := json.Unmarshal(body, &er) + return er, err + case string(TypeWebPage): + var wp WebPage + err := json.Unmarshal(body, &wp) + return wp, err + default: + var i Identifiable + err := json.Unmarshal(body, &i) + return i, err + } +} +func unmarshalBasicIdentifiableArray(body []byte) ([]BasicIdentifiable, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + iArray := make([]BasicIdentifiable, len(rawMessages)) + + for index, rawMessage := range rawMessages { + i, err := unmarshalBasicIdentifiable(*rawMessage) + if err != nil { + return nil, err + } + iArray[index] = i + } + return iArray, nil +} + +// MarshalJSON is the custom marshaler for Identifiable. +func (i Identifiable) MarshalJSON() ([]byte, error) { + i.Type = TypeIdentifiable + objectMap := make(map[string]interface{}) + if i.ID != nil { + objectMap["id"] = i.ID + } + if i.Type != "" { + objectMap["_type"] = i.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicResponse() (BasicResponse, bool) { + return nil, false +} + +// AsThing is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsIdentifiable() (*Identifiable, bool) { + return &i, true +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &i, true +} + +// AsErrorResponse is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for Identifiable. +func (i Identifiable) AsBasicResponseBase() (BasicResponseBase, bool) { + return &i, true +} + +// ImageObject defines an image +type ImageObject struct { + // Thumbnail - The URL to a thumbnail of the image + Thumbnail *ImageObject `json:"thumbnail,omitempty"` + // ImageInsightsToken - The token that you use in a subsequent call to the Image Search API to get additional information about the image. For information about using this token, see the insightsToken query parameter. + ImageInsightsToken *string `json:"imageInsightsToken,omitempty"` + // ImageID - Unique Id for the image + ImageID *string `json:"imageId,omitempty"` + // AccentColor - A three-byte hexadecimal number that represents the color that dominates the image. Use the color as the temporary background in your client until the image is loaded. + AccentColor *string `json:"accentColor,omitempty"` + // VisualWords - Visual representation of the image. Used for getting more sizes + VisualWords *string `json:"visualWords,omitempty"` + // ContentURL - Original URL to retrieve the source (file) for the media object (e.g the source URL for the image). + ContentURL *string `json:"contentUrl,omitempty"` + // HostPageURL - URL of the page that hosts the media object. + HostPageURL *string `json:"hostPageUrl,omitempty"` + // ContentSize - Size of the media object content (use format "value unit" e.g "1024 B"). + ContentSize *string `json:"contentSize,omitempty"` + // EncodingFormat - Encoding format (e.g mp3, mp4, jpeg, etc). + EncodingFormat *string `json:"encodingFormat,omitempty"` + // HostPageDisplayURL - Display URL of the page that hosts the media object. + HostPageDisplayURL *string `json:"hostPageDisplayUrl,omitempty"` + // Width - The width of the media object, in pixels. + Width *int32 `json:"width,omitempty"` + // Height - The height of the media object, in pixels. + Height *int32 `json:"height,omitempty"` + // ThumbnailURL - The URL to a thumbnail of the item. + ThumbnailURL *string `json:"thumbnailUrl,omitempty"` + // Provider - The source of the creative work. + Provider *[]BasicThing `json:"provider,omitempty"` + // Text - Text content of this creative work + Text *string `json:"text,omitempty"` + // Name - The name of the thing represented by this object. + Name *string `json:"name,omitempty"` + // URL - The URL to get more information about the thing represented by this object. + URL *string `json:"url,omitempty"` + // Image - An image of the item. + Image *ImageObject `json:"image,omitempty"` + // Description - A short description of the item. + Description *string `json:"description,omitempty"` + // AlternateName - An alias for the item + AlternateName *string `json:"alternateName,omitempty"` + // BingID - An ID that uniquely identifies this item. + BingID *string `json:"bingId,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ImageObject. +func (ioVar ImageObject) MarshalJSON() ([]byte, error) { + ioVar.Type = TypeImageObject + objectMap := make(map[string]interface{}) + if ioVar.Thumbnail != nil { + objectMap["thumbnail"] = ioVar.Thumbnail + } + if ioVar.ImageInsightsToken != nil { + objectMap["imageInsightsToken"] = ioVar.ImageInsightsToken + } + if ioVar.ImageID != nil { + objectMap["imageId"] = ioVar.ImageID + } + if ioVar.AccentColor != nil { + objectMap["accentColor"] = ioVar.AccentColor + } + if ioVar.VisualWords != nil { + objectMap["visualWords"] = ioVar.VisualWords + } + if ioVar.ContentURL != nil { + objectMap["contentUrl"] = ioVar.ContentURL + } + if ioVar.HostPageURL != nil { + objectMap["hostPageUrl"] = ioVar.HostPageURL + } + if ioVar.ContentSize != nil { + objectMap["contentSize"] = ioVar.ContentSize + } + if ioVar.EncodingFormat != nil { + objectMap["encodingFormat"] = ioVar.EncodingFormat + } + if ioVar.HostPageDisplayURL != nil { + objectMap["hostPageDisplayUrl"] = ioVar.HostPageDisplayURL + } + if ioVar.Width != nil { + objectMap["width"] = ioVar.Width + } + if ioVar.Height != nil { + objectMap["height"] = ioVar.Height + } + if ioVar.ThumbnailURL != nil { + objectMap["thumbnailUrl"] = ioVar.ThumbnailURL + } + if ioVar.Provider != nil { + objectMap["provider"] = ioVar.Provider + } + if ioVar.Text != nil { + objectMap["text"] = ioVar.Text + } + if ioVar.Name != nil { + objectMap["name"] = ioVar.Name + } + if ioVar.URL != nil { + objectMap["url"] = ioVar.URL + } + if ioVar.Image != nil { + objectMap["image"] = ioVar.Image + } + if ioVar.Description != nil { + objectMap["description"] = ioVar.Description + } + if ioVar.AlternateName != nil { + objectMap["alternateName"] = ioVar.AlternateName + } + if ioVar.BingID != nil { + objectMap["bingId"] = ioVar.BingID + } + if ioVar.ReadLink != nil { + objectMap["readLink"] = ioVar.ReadLink + } + if ioVar.WebSearchURL != nil { + objectMap["webSearchUrl"] = ioVar.WebSearchURL + } + if ioVar.ID != nil { + objectMap["id"] = ioVar.ID + } + if ioVar.Type != "" { + objectMap["_type"] = ioVar.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsImageObject() (*ImageObject, bool) { + return &ioVar, true +} + +// AsImages is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicMediaObject() (BasicMediaObject, bool) { + return &ioVar, true +} + +// AsResponse is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicResponse() (BasicResponse, bool) { + return &ioVar, true +} + +// AsThing is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicThing() (BasicThing, bool) { + return &ioVar, true +} + +// AsCreativeWork is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return &ioVar, true +} + +// AsIdentifiable is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &ioVar, true +} + +// AsErrorResponse is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for ImageObject. +func (ioVar ImageObject) AsBasicResponseBase() (BasicResponseBase, bool) { + return &ioVar, true +} + +// UnmarshalJSON is the custom unmarshaler for ImageObject struct. +func (ioVar *ImageObject) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "thumbnail": + if v != nil { + var thumbnail ImageObject + err = json.Unmarshal(*v, &thumbnail) + if err != nil { + return err + } + ioVar.Thumbnail = &thumbnail + } + case "imageInsightsToken": + if v != nil { + var imageInsightsToken string + err = json.Unmarshal(*v, &imageInsightsToken) + if err != nil { + return err + } + ioVar.ImageInsightsToken = &imageInsightsToken + } + case "imageId": + if v != nil { + var imageID string + err = json.Unmarshal(*v, &imageID) + if err != nil { + return err + } + ioVar.ImageID = &imageID + } + case "accentColor": + if v != nil { + var accentColor string + err = json.Unmarshal(*v, &accentColor) + if err != nil { + return err + } + ioVar.AccentColor = &accentColor + } + case "visualWords": + if v != nil { + var visualWords string + err = json.Unmarshal(*v, &visualWords) + if err != nil { + return err + } + ioVar.VisualWords = &visualWords + } + case "contentUrl": + if v != nil { + var contentURL string + err = json.Unmarshal(*v, &contentURL) + if err != nil { + return err + } + ioVar.ContentURL = &contentURL + } + case "hostPageUrl": + if v != nil { + var hostPageURL string + err = json.Unmarshal(*v, &hostPageURL) + if err != nil { + return err + } + ioVar.HostPageURL = &hostPageURL + } + case "contentSize": + if v != nil { + var contentSize string + err = json.Unmarshal(*v, &contentSize) + if err != nil { + return err + } + ioVar.ContentSize = &contentSize + } + case "encodingFormat": + if v != nil { + var encodingFormat string + err = json.Unmarshal(*v, &encodingFormat) + if err != nil { + return err + } + ioVar.EncodingFormat = &encodingFormat + } + case "hostPageDisplayUrl": + if v != nil { + var hostPageDisplayURL string + err = json.Unmarshal(*v, &hostPageDisplayURL) + if err != nil { + return err + } + ioVar.HostPageDisplayURL = &hostPageDisplayURL + } + case "width": + if v != nil { + var width int32 + err = json.Unmarshal(*v, &width) + if err != nil { + return err + } + ioVar.Width = &width + } + case "height": + if v != nil { + var height int32 + err = json.Unmarshal(*v, &height) + if err != nil { + return err + } + ioVar.Height = &height + } + case "thumbnailUrl": + if v != nil { + var thumbnailURL string + err = json.Unmarshal(*v, &thumbnailURL) + if err != nil { + return err + } + ioVar.ThumbnailURL = &thumbnailURL + } + case "provider": + if v != nil { + provider, err := unmarshalBasicThingArray(*v) + if err != nil { + return err + } + ioVar.Provider = &provider + } + case "text": + if v != nil { + var textVar string + err = json.Unmarshal(*v, &textVar) + if err != nil { + return err + } + ioVar.Text = &textVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ioVar.Name = &name + } + case "url": + if v != nil { + var URL string + err = json.Unmarshal(*v, &URL) + if err != nil { + return err + } + ioVar.URL = &URL + } + case "image": + if v != nil { + var imageVar ImageObject + err = json.Unmarshal(*v, &imageVar) + if err != nil { + return err + } + ioVar.Image = &imageVar + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + ioVar.Description = &description + } + case "alternateName": + if v != nil { + var alternateName string + err = json.Unmarshal(*v, &alternateName) + if err != nil { + return err + } + ioVar.AlternateName = &alternateName + } + case "bingId": + if v != nil { + var bingID string + err = json.Unmarshal(*v, &bingID) + if err != nil { + return err + } + ioVar.BingID = &bingID + } + case "readLink": + if v != nil { + var readLink string + err = json.Unmarshal(*v, &readLink) + if err != nil { + return err + } + ioVar.ReadLink = &readLink + } + case "webSearchUrl": + if v != nil { + var webSearchURL string + err = json.Unmarshal(*v, &webSearchURL) + if err != nil { + return err + } + ioVar.WebSearchURL = &webSearchURL + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ioVar.ID = &ID + } + case "_type": + if v != nil { + var typeVar Type + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ioVar.Type = typeVar + } + } + } + + return nil +} + +// Images defines an image answer +type Images struct { + autorest.Response `json:"-"` + // NextOffset - Used as part of deduping. Tells client the next offset that client should use in the next pagination request + NextOffset *int32 `json:"nextOffset,omitempty"` + // Value - A list of image objects that are relevant to the query. If there are no results, the List is empty. + Value *[]ImageObject `json:"value,omitempty"` + // TotalEstimatedMatches - The estimated number of webpages that are relevant to the query. Use this number along with the count and offset query parameters to page the results. + TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Images. +func (i Images) MarshalJSON() ([]byte, error) { + i.Type = TypeImages + objectMap := make(map[string]interface{}) + if i.NextOffset != nil { + objectMap["nextOffset"] = i.NextOffset + } + if i.Value != nil { + objectMap["value"] = i.Value + } + if i.TotalEstimatedMatches != nil { + objectMap["totalEstimatedMatches"] = i.TotalEstimatedMatches + } + if i.ReadLink != nil { + objectMap["readLink"] = i.ReadLink + } + if i.WebSearchURL != nil { + objectMap["webSearchUrl"] = i.WebSearchURL + } + if i.ID != nil { + objectMap["id"] = i.ID + } + if i.Type != "" { + objectMap["_type"] = i.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for Images. +func (i Images) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for Images. +func (i Images) AsImages() (*Images, bool) { + return &i, true +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for Images. +func (i Images) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Images. +func (i Images) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return &i, true +} + +// AsAnswer is the BasicResponseBase implementation for Images. +func (i Images) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for Images. +func (i Images) AsBasicAnswer() (BasicAnswer, bool) { + return &i, true +} + +// AsMediaObject is the BasicResponseBase implementation for Images. +func (i Images) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for Images. +func (i Images) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for Images. +func (i Images) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for Images. +func (i Images) AsBasicResponse() (BasicResponse, bool) { + return &i, true +} + +// AsThing is the BasicResponseBase implementation for Images. +func (i Images) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for Images. +func (i Images) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for Images. +func (i Images) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for Images. +func (i Images) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for Images. +func (i Images) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for Images. +func (i Images) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &i, true +} + +// AsErrorResponse is the BasicResponseBase implementation for Images. +func (i Images) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for Images. +func (i Images) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for Images. +func (i Images) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for Images. +func (i Images) AsBasicResponseBase() (BasicResponseBase, bool) { + return &i, true +} + +// BasicMediaObject defines a media object. +type BasicMediaObject interface { + AsImageObject() (*ImageObject, bool) + AsMediaObject() (*MediaObject, bool) +} + +// MediaObject defines a media object. +type MediaObject struct { + // ContentURL - Original URL to retrieve the source (file) for the media object (e.g the source URL for the image). + ContentURL *string `json:"contentUrl,omitempty"` + // HostPageURL - URL of the page that hosts the media object. + HostPageURL *string `json:"hostPageUrl,omitempty"` + // ContentSize - Size of the media object content (use format "value unit" e.g "1024 B"). + ContentSize *string `json:"contentSize,omitempty"` + // EncodingFormat - Encoding format (e.g mp3, mp4, jpeg, etc). + EncodingFormat *string `json:"encodingFormat,omitempty"` + // HostPageDisplayURL - Display URL of the page that hosts the media object. + HostPageDisplayURL *string `json:"hostPageDisplayUrl,omitempty"` + // Width - The width of the media object, in pixels. + Width *int32 `json:"width,omitempty"` + // Height - The height of the media object, in pixels. + Height *int32 `json:"height,omitempty"` + // ThumbnailURL - The URL to a thumbnail of the item. + ThumbnailURL *string `json:"thumbnailUrl,omitempty"` + // Provider - The source of the creative work. + Provider *[]BasicThing `json:"provider,omitempty"` + // Text - Text content of this creative work + Text *string `json:"text,omitempty"` + // Name - The name of the thing represented by this object. + Name *string `json:"name,omitempty"` + // URL - The URL to get more information about the thing represented by this object. + URL *string `json:"url,omitempty"` + // Image - An image of the item. + Image *ImageObject `json:"image,omitempty"` + // Description - A short description of the item. + Description *string `json:"description,omitempty"` + // AlternateName - An alias for the item + AlternateName *string `json:"alternateName,omitempty"` + // BingID - An ID that uniquely identifies this item. + BingID *string `json:"bingId,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicMediaObject(body []byte) (BasicMediaObject, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImageObject): + var ioVar ImageObject + err := json.Unmarshal(body, &ioVar) + return ioVar, err + default: + var mo MediaObject + err := json.Unmarshal(body, &mo) + return mo, err + } +} +func unmarshalBasicMediaObjectArray(body []byte) ([]BasicMediaObject, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + moArray := make([]BasicMediaObject, len(rawMessages)) + + for index, rawMessage := range rawMessages { + mo, err := unmarshalBasicMediaObject(*rawMessage) + if err != nil { + return nil, err + } + moArray[index] = mo + } + return moArray, nil +} + +// MarshalJSON is the custom marshaler for MediaObject. +func (mo MediaObject) MarshalJSON() ([]byte, error) { + mo.Type = TypeMediaObject + objectMap := make(map[string]interface{}) + if mo.ContentURL != nil { + objectMap["contentUrl"] = mo.ContentURL + } + if mo.HostPageURL != nil { + objectMap["hostPageUrl"] = mo.HostPageURL + } + if mo.ContentSize != nil { + objectMap["contentSize"] = mo.ContentSize + } + if mo.EncodingFormat != nil { + objectMap["encodingFormat"] = mo.EncodingFormat + } + if mo.HostPageDisplayURL != nil { + objectMap["hostPageDisplayUrl"] = mo.HostPageDisplayURL + } + if mo.Width != nil { + objectMap["width"] = mo.Width + } + if mo.Height != nil { + objectMap["height"] = mo.Height + } + if mo.ThumbnailURL != nil { + objectMap["thumbnailUrl"] = mo.ThumbnailURL + } + if mo.Provider != nil { + objectMap["provider"] = mo.Provider + } + if mo.Text != nil { + objectMap["text"] = mo.Text + } + if mo.Name != nil { + objectMap["name"] = mo.Name + } + if mo.URL != nil { + objectMap["url"] = mo.URL + } + if mo.Image != nil { + objectMap["image"] = mo.Image + } + if mo.Description != nil { + objectMap["description"] = mo.Description + } + if mo.AlternateName != nil { + objectMap["alternateName"] = mo.AlternateName + } + if mo.BingID != nil { + objectMap["bingId"] = mo.BingID + } + if mo.ReadLink != nil { + objectMap["readLink"] = mo.ReadLink + } + if mo.WebSearchURL != nil { + objectMap["webSearchUrl"] = mo.WebSearchURL + } + if mo.ID != nil { + objectMap["id"] = mo.ID + } + if mo.Type != "" { + objectMap["_type"] = mo.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsMediaObject() (*MediaObject, bool) { + return &mo, true +} + +// AsBasicMediaObject is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicMediaObject() (BasicMediaObject, bool) { + return &mo, true +} + +// AsResponse is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicResponse() (BasicResponse, bool) { + return &mo, true +} + +// AsThing is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicThing() (BasicThing, bool) { + return &mo, true +} + +// AsCreativeWork is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return &mo, true +} + +// AsIdentifiable is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &mo, true +} + +// AsErrorResponse is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for MediaObject. +func (mo MediaObject) AsBasicResponseBase() (BasicResponseBase, bool) { + return &mo, true +} + +// UnmarshalJSON is the custom unmarshaler for MediaObject struct. +func (mo *MediaObject) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "contentUrl": + if v != nil { + var contentURL string + err = json.Unmarshal(*v, &contentURL) + if err != nil { + return err + } + mo.ContentURL = &contentURL + } + case "hostPageUrl": + if v != nil { + var hostPageURL string + err = json.Unmarshal(*v, &hostPageURL) + if err != nil { + return err + } + mo.HostPageURL = &hostPageURL + } + case "contentSize": + if v != nil { + var contentSize string + err = json.Unmarshal(*v, &contentSize) + if err != nil { + return err + } + mo.ContentSize = &contentSize + } + case "encodingFormat": + if v != nil { + var encodingFormat string + err = json.Unmarshal(*v, &encodingFormat) + if err != nil { + return err + } + mo.EncodingFormat = &encodingFormat + } + case "hostPageDisplayUrl": + if v != nil { + var hostPageDisplayURL string + err = json.Unmarshal(*v, &hostPageDisplayURL) + if err != nil { + return err + } + mo.HostPageDisplayURL = &hostPageDisplayURL + } + case "width": + if v != nil { + var width int32 + err = json.Unmarshal(*v, &width) + if err != nil { + return err + } + mo.Width = &width + } + case "height": + if v != nil { + var height int32 + err = json.Unmarshal(*v, &height) + if err != nil { + return err + } + mo.Height = &height + } + case "thumbnailUrl": + if v != nil { + var thumbnailURL string + err = json.Unmarshal(*v, &thumbnailURL) + if err != nil { + return err + } + mo.ThumbnailURL = &thumbnailURL + } + case "provider": + if v != nil { + provider, err := unmarshalBasicThingArray(*v) + if err != nil { + return err + } + mo.Provider = &provider + } + case "text": + if v != nil { + var textVar string + err = json.Unmarshal(*v, &textVar) + if err != nil { + return err + } + mo.Text = &textVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mo.Name = &name + } + case "url": + if v != nil { + var URL string + err = json.Unmarshal(*v, &URL) + if err != nil { + return err + } + mo.URL = &URL + } + case "image": + if v != nil { + var imageVar ImageObject + err = json.Unmarshal(*v, &imageVar) + if err != nil { + return err + } + mo.Image = &imageVar + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + mo.Description = &description + } + case "alternateName": + if v != nil { + var alternateName string + err = json.Unmarshal(*v, &alternateName) + if err != nil { + return err + } + mo.AlternateName = &alternateName + } + case "bingId": + if v != nil { + var bingID string + err = json.Unmarshal(*v, &bingID) + if err != nil { + return err + } + mo.BingID = &bingID + } + case "readLink": + if v != nil { + var readLink string + err = json.Unmarshal(*v, &readLink) + if err != nil { + return err + } + mo.ReadLink = &readLink + } + case "webSearchUrl": + if v != nil { + var webSearchURL string + err = json.Unmarshal(*v, &webSearchURL) + if err != nil { + return err + } + mo.WebSearchURL = &webSearchURL + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + mo.ID = &ID + } + case "_type": + if v != nil { + var typeVar Type + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + mo.Type = typeVar + } + } + } + + return nil +} + +// Query defines a search query. +type Query struct { + // Text - The query string. Use this string as the query term in a new search request. + Text *string `json:"text,omitempty"` + // DisplayText - The display version of the query term. This version of the query term may contain special characters that highlight the search term found in the query string. The string contains the highlighting characters only if the query enabled hit highlighting + DisplayText *string `json:"displayText,omitempty"` + // WebSearchURL - The URL that takes the user to the Bing search results page for the query.Only related search results include this field. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // SearchLink - The URL that you use to get the results of the related search. Before using the URL, you must append query parameters as appropriate and include the Ocp-Apim-Subscription-Key header. Use this URL if you're displaying the results in your own user interface. Otherwise, use the webSearchUrl URL. + SearchLink *string `json:"searchLink,omitempty"` + // Thumbnail - The URL to a thumbnail of a related image. + Thumbnail *ImageObject `json:"thumbnail,omitempty"` +} + +// BasicResponse defines a response. All schemas that could be returned at the root of a response should inherit from +// this +type BasicResponse interface { + AsImageObject() (*ImageObject, bool) + AsImages() (*Images, bool) + AsSearchResultsAnswer() (*SearchResultsAnswer, bool) + AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) + AsAnswer() (*Answer, bool) + AsBasicAnswer() (BasicAnswer, bool) + AsMediaObject() (*MediaObject, bool) + AsBasicMediaObject() (BasicMediaObject, bool) + AsThing() (*Thing, bool) + AsBasicThing() (BasicThing, bool) + AsCreativeWork() (*CreativeWork, bool) + AsBasicCreativeWork() (BasicCreativeWork, bool) + AsErrorResponse() (*ErrorResponse, bool) + AsWebPage() (*WebPage, bool) + AsResponse() (*Response, bool) +} + +// Response defines a response. All schemas that could be returned at the root of a response should inherit from +// this +type Response struct { + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicResponse(body []byte) (BasicResponse, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImageObject): + var ioVar ImageObject + err := json.Unmarshal(body, &ioVar) + return ioVar, err + case string(TypeImages): + var i Images + err := json.Unmarshal(body, &i) + return i, err + case string(TypeSearchResultsAnswer): + var sra SearchResultsAnswer + err := json.Unmarshal(body, &sra) + return sra, err + case string(TypeAnswer): + var a Answer + err := json.Unmarshal(body, &a) + return a, err + case string(TypeMediaObject): + var mo MediaObject + err := json.Unmarshal(body, &mo) + return mo, err + case string(TypeThing): + var t Thing + err := json.Unmarshal(body, &t) + return t, err + case string(TypeCreativeWork): + var cw CreativeWork + err := json.Unmarshal(body, &cw) + return cw, err + case string(TypeErrorResponse): + var er ErrorResponse + err := json.Unmarshal(body, &er) + return er, err + case string(TypeWebPage): + var wp WebPage + err := json.Unmarshal(body, &wp) + return wp, err + default: + var r Response + err := json.Unmarshal(body, &r) + return r, err + } +} +func unmarshalBasicResponseArray(body []byte) ([]BasicResponse, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rArray := make([]BasicResponse, len(rawMessages)) + + for index, rawMessage := range rawMessages { + r, err := unmarshalBasicResponse(*rawMessage) + if err != nil { + return nil, err + } + rArray[index] = r + } + return rArray, nil +} + +// MarshalJSON is the custom marshaler for Response. +func (r Response) MarshalJSON() ([]byte, error) { + r.Type = TypeResponse + objectMap := make(map[string]interface{}) + if r.ReadLink != nil { + objectMap["readLink"] = r.ReadLink + } + if r.WebSearchURL != nil { + objectMap["webSearchUrl"] = r.WebSearchURL + } + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Type != "" { + objectMap["_type"] = r.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for Response. +func (r Response) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for Response. +func (r Response) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for Response. +func (r Response) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Response. +func (r Response) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for Response. +func (r Response) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for Response. +func (r Response) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for Response. +func (r Response) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for Response. +func (r Response) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for Response. +func (r Response) AsResponse() (*Response, bool) { + return &r, true +} + +// AsBasicResponse is the BasicResponseBase implementation for Response. +func (r Response) AsBasicResponse() (BasicResponse, bool) { + return &r, true +} + +// AsThing is the BasicResponseBase implementation for Response. +func (r Response) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for Response. +func (r Response) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for Response. +func (r Response) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for Response. +func (r Response) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for Response. +func (r Response) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for Response. +func (r Response) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &r, true +} + +// AsErrorResponse is the BasicResponseBase implementation for Response. +func (r Response) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for Response. +func (r Response) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for Response. +func (r Response) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for Response. +func (r Response) AsBasicResponseBase() (BasicResponseBase, bool) { + return &r, true +} + +// BasicResponseBase response base +type BasicResponseBase interface { + AsImageObject() (*ImageObject, bool) + AsImages() (*Images, bool) + AsSearchResultsAnswer() (*SearchResultsAnswer, bool) + AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) + AsAnswer() (*Answer, bool) + AsBasicAnswer() (BasicAnswer, bool) + AsMediaObject() (*MediaObject, bool) + AsBasicMediaObject() (BasicMediaObject, bool) + AsResponse() (*Response, bool) + AsBasicResponse() (BasicResponse, bool) + AsThing() (*Thing, bool) + AsBasicThing() (BasicThing, bool) + AsCreativeWork() (*CreativeWork, bool) + AsBasicCreativeWork() (BasicCreativeWork, bool) + AsIdentifiable() (*Identifiable, bool) + AsBasicIdentifiable() (BasicIdentifiable, bool) + AsErrorResponse() (*ErrorResponse, bool) + AsWebPage() (*WebPage, bool) + AsResponseBase() (*ResponseBase, bool) +} + +// ResponseBase response base +type ResponseBase struct { + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicResponseBase(body []byte) (BasicResponseBase, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImageObject): + var ioVar ImageObject + err := json.Unmarshal(body, &ioVar) + return ioVar, err + case string(TypeImages): + var i Images + err := json.Unmarshal(body, &i) + return i, err + case string(TypeSearchResultsAnswer): + var sra SearchResultsAnswer + err := json.Unmarshal(body, &sra) + return sra, err + case string(TypeAnswer): + var a Answer + err := json.Unmarshal(body, &a) + return a, err + case string(TypeMediaObject): + var mo MediaObject + err := json.Unmarshal(body, &mo) + return mo, err + case string(TypeResponse): + var r Response + err := json.Unmarshal(body, &r) + return r, err + case string(TypeThing): + var t Thing + err := json.Unmarshal(body, &t) + return t, err + case string(TypeCreativeWork): + var cw CreativeWork + err := json.Unmarshal(body, &cw) + return cw, err + case string(TypeIdentifiable): + var i Identifiable + err := json.Unmarshal(body, &i) + return i, err + case string(TypeErrorResponse): + var er ErrorResponse + err := json.Unmarshal(body, &er) + return er, err + case string(TypeWebPage): + var wp WebPage + err := json.Unmarshal(body, &wp) + return wp, err + default: + var rb ResponseBase + err := json.Unmarshal(body, &rb) + return rb, err + } +} +func unmarshalBasicResponseBaseArray(body []byte) ([]BasicResponseBase, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + rbArray := make([]BasicResponseBase, len(rawMessages)) + + for index, rawMessage := range rawMessages { + rb, err := unmarshalBasicResponseBase(*rawMessage) + if err != nil { + return nil, err + } + rbArray[index] = rb + } + return rbArray, nil +} + +// MarshalJSON is the custom marshaler for ResponseBase. +func (rb ResponseBase) MarshalJSON() ([]byte, error) { + rb.Type = TypeResponseBase + objectMap := make(map[string]interface{}) + if rb.Type != "" { + objectMap["_type"] = rb.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicResponse() (BasicResponse, bool) { + return nil, false +} + +// AsThing is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return nil, false +} + +// AsErrorResponse is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsResponseBase() (*ResponseBase, bool) { + return &rb, true +} + +// AsBasicResponseBase is the BasicResponseBase implementation for ResponseBase. +func (rb ResponseBase) AsBasicResponseBase() (BasicResponseBase, bool) { + return &rb, true +} + +// BasicSearchResultsAnswer defines a search result answer. +type BasicSearchResultsAnswer interface { + AsImages() (*Images, bool) + AsSearchResultsAnswer() (*SearchResultsAnswer, bool) +} + +// SearchResultsAnswer defines a search result answer. +type SearchResultsAnswer struct { + // TotalEstimatedMatches - The estimated number of webpages that are relevant to the query. Use this number along with the count and offset query parameters to page the results. + TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicSearchResultsAnswer(body []byte) (BasicSearchResultsAnswer, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImages): + var i Images + err := json.Unmarshal(body, &i) + return i, err + default: + var sra SearchResultsAnswer + err := json.Unmarshal(body, &sra) + return sra, err + } +} +func unmarshalBasicSearchResultsAnswerArray(body []byte) ([]BasicSearchResultsAnswer, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + sraArray := make([]BasicSearchResultsAnswer, len(rawMessages)) + + for index, rawMessage := range rawMessages { + sra, err := unmarshalBasicSearchResultsAnswer(*rawMessage) + if err != nil { + return nil, err + } + sraArray[index] = sra + } + return sraArray, nil +} + +// MarshalJSON is the custom marshaler for SearchResultsAnswer. +func (sra SearchResultsAnswer) MarshalJSON() ([]byte, error) { + sra.Type = TypeSearchResultsAnswer + objectMap := make(map[string]interface{}) + if sra.TotalEstimatedMatches != nil { + objectMap["totalEstimatedMatches"] = sra.TotalEstimatedMatches + } + if sra.ReadLink != nil { + objectMap["readLink"] = sra.ReadLink + } + if sra.WebSearchURL != nil { + objectMap["webSearchUrl"] = sra.WebSearchURL + } + if sra.ID != nil { + objectMap["id"] = sra.ID + } + if sra.Type != "" { + objectMap["_type"] = sra.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return &sra, true +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return &sra, true +} + +// AsAnswer is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicAnswer() (BasicAnswer, bool) { + return &sra, true +} + +// AsMediaObject is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicResponse() (BasicResponse, bool) { + return &sra, true +} + +// AsThing is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicThing() (BasicThing, bool) { + return nil, false +} + +// AsCreativeWork is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &sra, true +} + +// AsErrorResponse is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for SearchResultsAnswer. +func (sra SearchResultsAnswer) AsBasicResponseBase() (BasicResponseBase, bool) { + return &sra, true +} + +// BasicThing defines a thing. +type BasicThing interface { + AsImageObject() (*ImageObject, bool) + AsMediaObject() (*MediaObject, bool) + AsBasicMediaObject() (BasicMediaObject, bool) + AsCreativeWork() (*CreativeWork, bool) + AsBasicCreativeWork() (BasicCreativeWork, bool) + AsWebPage() (*WebPage, bool) + AsThing() (*Thing, bool) +} + +// Thing defines a thing. +type Thing struct { + // Name - The name of the thing represented by this object. + Name *string `json:"name,omitempty"` + // URL - The URL to get more information about the thing represented by this object. + URL *string `json:"url,omitempty"` + // Image - An image of the item. + Image *ImageObject `json:"image,omitempty"` + // Description - A short description of the item. + Description *string `json:"description,omitempty"` + // AlternateName - An alias for the item + AlternateName *string `json:"alternateName,omitempty"` + // BingID - An ID that uniquely identifies this item. + BingID *string `json:"bingId,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +func unmarshalBasicThing(body []byte) (BasicThing, error) { + var m map[string]interface{} + err := json.Unmarshal(body, &m) + if err != nil { + return nil, err + } + + switch m["_type"] { + case string(TypeImageObject): + var ioVar ImageObject + err := json.Unmarshal(body, &ioVar) + return ioVar, err + case string(TypeMediaObject): + var mo MediaObject + err := json.Unmarshal(body, &mo) + return mo, err + case string(TypeCreativeWork): + var cw CreativeWork + err := json.Unmarshal(body, &cw) + return cw, err + case string(TypeWebPage): + var wp WebPage + err := json.Unmarshal(body, &wp) + return wp, err + default: + var t Thing + err := json.Unmarshal(body, &t) + return t, err + } +} +func unmarshalBasicThingArray(body []byte) ([]BasicThing, error) { + var rawMessages []*json.RawMessage + err := json.Unmarshal(body, &rawMessages) + if err != nil { + return nil, err + } + + tArray := make([]BasicThing, len(rawMessages)) + + for index, rawMessage := range rawMessages { + t, err := unmarshalBasicThing(*rawMessage) + if err != nil { + return nil, err + } + tArray[index] = t + } + return tArray, nil +} + +// MarshalJSON is the custom marshaler for Thing. +func (t Thing) MarshalJSON() ([]byte, error) { + t.Type = TypeThing + objectMap := make(map[string]interface{}) + if t.Name != nil { + objectMap["name"] = t.Name + } + if t.URL != nil { + objectMap["url"] = t.URL + } + if t.Image != nil { + objectMap["image"] = t.Image + } + if t.Description != nil { + objectMap["description"] = t.Description + } + if t.AlternateName != nil { + objectMap["alternateName"] = t.AlternateName + } + if t.BingID != nil { + objectMap["bingId"] = t.BingID + } + if t.ReadLink != nil { + objectMap["readLink"] = t.ReadLink + } + if t.WebSearchURL != nil { + objectMap["webSearchUrl"] = t.WebSearchURL + } + if t.ID != nil { + objectMap["id"] = t.ID + } + if t.Type != "" { + objectMap["_type"] = t.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for Thing. +func (t Thing) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for Thing. +func (t Thing) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for Thing. +func (t Thing) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for Thing. +func (t Thing) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for Thing. +func (t Thing) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for Thing. +func (t Thing) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicResponse() (BasicResponse, bool) { + return &t, true +} + +// AsThing is the BasicResponseBase implementation for Thing. +func (t Thing) AsThing() (*Thing, bool) { + return &t, true +} + +// AsBasicThing is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicThing() (BasicThing, bool) { + return &t, true +} + +// AsCreativeWork is the BasicResponseBase implementation for Thing. +func (t Thing) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return nil, false +} + +// AsIdentifiable is the BasicResponseBase implementation for Thing. +func (t Thing) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &t, true +} + +// AsErrorResponse is the BasicResponseBase implementation for Thing. +func (t Thing) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for Thing. +func (t Thing) AsWebPage() (*WebPage, bool) { + return nil, false +} + +// AsResponseBase is the BasicResponseBase implementation for Thing. +func (t Thing) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for Thing. +func (t Thing) AsBasicResponseBase() (BasicResponseBase, bool) { + return &t, true +} + +// WebPage defines a webpage that is relevant to the query. +type WebPage struct { + // ThumbnailURL - The URL to a thumbnail of the item. + ThumbnailURL *string `json:"thumbnailUrl,omitempty"` + // Provider - The source of the creative work. + Provider *[]BasicThing `json:"provider,omitempty"` + // Text - Text content of this creative work + Text *string `json:"text,omitempty"` + // Name - The name of the thing represented by this object. + Name *string `json:"name,omitempty"` + // URL - The URL to get more information about the thing represented by this object. + URL *string `json:"url,omitempty"` + // Image - An image of the item. + Image *ImageObject `json:"image,omitempty"` + // Description - A short description of the item. + Description *string `json:"description,omitempty"` + // AlternateName - An alias for the item + AlternateName *string `json:"alternateName,omitempty"` + // BingID - An ID that uniquely identifies this item. + BingID *string `json:"bingId,omitempty"` + // ReadLink - The URL that returns this resource. + ReadLink *string `json:"readLink,omitempty"` + // WebSearchURL - The URL To Bing's search result for this item. + WebSearchURL *string `json:"webSearchUrl,omitempty"` + // ID - A String identifier. + ID *string `json:"id,omitempty"` + // Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage' + Type Type `json:"_type,omitempty"` +} + +// MarshalJSON is the custom marshaler for WebPage. +func (wp WebPage) MarshalJSON() ([]byte, error) { + wp.Type = TypeWebPage + objectMap := make(map[string]interface{}) + if wp.ThumbnailURL != nil { + objectMap["thumbnailUrl"] = wp.ThumbnailURL + } + if wp.Provider != nil { + objectMap["provider"] = wp.Provider + } + if wp.Text != nil { + objectMap["text"] = wp.Text + } + if wp.Name != nil { + objectMap["name"] = wp.Name + } + if wp.URL != nil { + objectMap["url"] = wp.URL + } + if wp.Image != nil { + objectMap["image"] = wp.Image + } + if wp.Description != nil { + objectMap["description"] = wp.Description + } + if wp.AlternateName != nil { + objectMap["alternateName"] = wp.AlternateName + } + if wp.BingID != nil { + objectMap["bingId"] = wp.BingID + } + if wp.ReadLink != nil { + objectMap["readLink"] = wp.ReadLink + } + if wp.WebSearchURL != nil { + objectMap["webSearchUrl"] = wp.WebSearchURL + } + if wp.ID != nil { + objectMap["id"] = wp.ID + } + if wp.Type != "" { + objectMap["_type"] = wp.Type + } + return json.Marshal(objectMap) +} + +// AsImageObject is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsImageObject() (*ImageObject, bool) { + return nil, false +} + +// AsImages is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsImages() (*Images, bool) { + return nil, false +} + +// AsSearchResultsAnswer is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) { + return nil, false +} + +// AsBasicSearchResultsAnswer is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) { + return nil, false +} + +// AsAnswer is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsAnswer() (*Answer, bool) { + return nil, false +} + +// AsBasicAnswer is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicAnswer() (BasicAnswer, bool) { + return nil, false +} + +// AsMediaObject is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsMediaObject() (*MediaObject, bool) { + return nil, false +} + +// AsBasicMediaObject is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicMediaObject() (BasicMediaObject, bool) { + return nil, false +} + +// AsResponse is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsResponse() (*Response, bool) { + return nil, false +} + +// AsBasicResponse is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicResponse() (BasicResponse, bool) { + return &wp, true +} + +// AsThing is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsThing() (*Thing, bool) { + return nil, false +} + +// AsBasicThing is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicThing() (BasicThing, bool) { + return &wp, true +} + +// AsCreativeWork is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsCreativeWork() (*CreativeWork, bool) { + return nil, false +} + +// AsBasicCreativeWork is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicCreativeWork() (BasicCreativeWork, bool) { + return &wp, true +} + +// AsIdentifiable is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsIdentifiable() (*Identifiable, bool) { + return nil, false +} + +// AsBasicIdentifiable is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicIdentifiable() (BasicIdentifiable, bool) { + return &wp, true +} + +// AsErrorResponse is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsErrorResponse() (*ErrorResponse, bool) { + return nil, false +} + +// AsWebPage is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsWebPage() (*WebPage, bool) { + return &wp, true +} + +// AsResponseBase is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsResponseBase() (*ResponseBase, bool) { + return nil, false +} + +// AsBasicResponseBase is the BasicResponseBase implementation for WebPage. +func (wp WebPage) AsBasicResponseBase() (BasicResponseBase, bool) { + return &wp, true +} + +// UnmarshalJSON is the custom unmarshaler for WebPage struct. +func (wp *WebPage) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "thumbnailUrl": + if v != nil { + var thumbnailURL string + err = json.Unmarshal(*v, &thumbnailURL) + if err != nil { + return err + } + wp.ThumbnailURL = &thumbnailURL + } + case "provider": + if v != nil { + provider, err := unmarshalBasicThingArray(*v) + if err != nil { + return err + } + wp.Provider = &provider + } + case "text": + if v != nil { + var textVar string + err = json.Unmarshal(*v, &textVar) + if err != nil { + return err + } + wp.Text = &textVar + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + wp.Name = &name + } + case "url": + if v != nil { + var URL string + err = json.Unmarshal(*v, &URL) + if err != nil { + return err + } + wp.URL = &URL + } + case "image": + if v != nil { + var imageVar ImageObject + err = json.Unmarshal(*v, &imageVar) + if err != nil { + return err + } + wp.Image = &imageVar + } + case "description": + if v != nil { + var description string + err = json.Unmarshal(*v, &description) + if err != nil { + return err + } + wp.Description = &description + } + case "alternateName": + if v != nil { + var alternateName string + err = json.Unmarshal(*v, &alternateName) + if err != nil { + return err + } + wp.AlternateName = &alternateName + } + case "bingId": + if v != nil { + var bingID string + err = json.Unmarshal(*v, &bingID) + if err != nil { + return err + } + wp.BingID = &bingID + } + case "readLink": + if v != nil { + var readLink string + err = json.Unmarshal(*v, &readLink) + if err != nil { + return err + } + wp.ReadLink = &readLink + } + case "webSearchUrl": + if v != nil { + var webSearchURL string + err = json.Unmarshal(*v, &webSearchURL) + if err != nil { + return err + } + wp.WebSearchURL = &webSearchURL + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + wp.ID = &ID + } + case "_type": + if v != nil { + var typeVar Type + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + wp.Type = typeVar + } + } + } + + return nil +} diff --git a/services/cognitiveservices/v1.0/customimagesearch/version.go b/services/cognitiveservices/v1.0/customimagesearch/version.go new file mode 100644 index 000000000000..c84001cc6e0d --- /dev/null +++ b/services/cognitiveservices/v1.0/customimagesearch/version.go @@ -0,0 +1,30 @@ +package customimagesearch + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. 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. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License 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. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " customimagesearch/1.0" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}