vendor: update all dependencies to latest versions
This commit is contained in:
Generated
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Package face implements the Azure ARM Face service API version 1.0.
|
||||
//
|
||||
// An API for face detection, verification, and identification.
|
||||
package face
|
||||
|
||||
// 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 ()
|
||||
|
||||
// ManagementClient is the base client for Face.
|
||||
type ManagementClient struct {
|
||||
autorest.Client
|
||||
SubscriptionKey string
|
||||
AzureRegion AzureRegions
|
||||
}
|
||||
|
||||
// New creates an instance of the ManagementClient client.
|
||||
func New(subscriptionKey string, azureRegion AzureRegions) ManagementClient {
|
||||
return NewWithoutDefaults(subscriptionKey, azureRegion)
|
||||
}
|
||||
|
||||
// NewWithoutDefaults creates an instance of the ManagementClient client.
|
||||
func NewWithoutDefaults(subscriptionKey string, azureRegion AzureRegions) ManagementClient {
|
||||
return ManagementClient{
|
||||
Client: autorest.NewClientWithUserAgent(UserAgent()),
|
||||
SubscriptionKey: subscriptionKey,
|
||||
AzureRegion: azureRegion,
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+483
@@ -0,0 +1,483 @@
|
||||
package face
|
||||
|
||||
// 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"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GroupClient is the an API for face detection, verification, and identification.
|
||||
type GroupClient struct {
|
||||
ManagementClient
|
||||
}
|
||||
|
||||
// NewGroupClient creates an instance of the GroupClient client.
|
||||
func NewGroupClient(subscriptionKey string, azureRegion AzureRegions) GroupClient {
|
||||
return GroupClient{New(subscriptionKey, azureRegion)}
|
||||
}
|
||||
|
||||
// Detect detect human faces in an image and returns face locations, and optionally with faceIds, landmarks, and
|
||||
// attributes.
|
||||
//
|
||||
// imageURL is a JSON document with a URL pointing to the image that is to be analyzed. returnFaceID is a value
|
||||
// indicating whether the operation should return faceIds of detected faces. returnFaceLandmarks is a value indicating
|
||||
// whether the operation should return landmarks of the detected faces. returnFaceAttributes is analyze and return the
|
||||
// one or more specified face attributes in the comma-separated string like "returnFaceAttributes=age,gender".
|
||||
// Supported face attributes include age, gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
||||
// attribute analysis has additional computational and time cost.
|
||||
func (client GroupClient) Detect(imageURL ImageURL, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (result ListDetectedFace, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: imageURL,
|
||||
Constraints: []validation.Constraint{{Target: "imageURL.URL", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Detect")
|
||||
}
|
||||
|
||||
req, err := client.DetectPreparer(imageURL, returnFaceID, returnFaceLandmarks, returnFaceAttributes)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Detect", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DetectSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Detect", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DetectResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Detect", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetectPreparer prepares the Detect request.
|
||||
func (client GroupClient) DetectPreparer(imageURL ImageURL, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if returnFaceID != nil {
|
||||
queryParameters["returnFaceId"] = autorest.Encode("query", *returnFaceID)
|
||||
}
|
||||
if returnFaceLandmarks != nil {
|
||||
queryParameters["returnFaceLandmarks"] = autorest.Encode("query", *returnFaceLandmarks)
|
||||
}
|
||||
if len(returnFaceAttributes) > 0 {
|
||||
queryParameters["returnFaceAttributes"] = autorest.Encode("query", returnFaceAttributes)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/detect"),
|
||||
autorest.WithJSON(imageURL),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DetectSender sends the Detect request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client GroupClient) DetectSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DetectResponder handles the response to the Detect request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client GroupClient) DetectResponder(resp *http.Response) (result ListDetectedFace, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// DetectInStream detect human faces in an image and returns face locations, and optionally with faceIds, landmarks,
|
||||
// and attributes.
|
||||
//
|
||||
// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure
|
||||
// closure when receiving an error.returnFaceID is a value indicating whether the operation should return faceIds of
|
||||
// detected faces. returnFaceLandmarks is a value indicating whether the operation should return landmarks of the
|
||||
// detected faces. returnFaceAttributes is analyze and return the one or more specified face attributes in the
|
||||
// comma-separated string like "returnFaceAttributes=age,gender". Supported face attributes include age, gender,
|
||||
// headPose, smile, facialHair, glasses and emotion. Note that each face attribute analysis has additional
|
||||
// computational and time cost.
|
||||
func (client GroupClient) DetectInStream(imageParameter io.ReadCloser, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (result ListDetectedFace, err error) {
|
||||
req, err := client.DetectInStreamPreparer(imageParameter, returnFaceID, returnFaceLandmarks, returnFaceAttributes)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "DetectInStream", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DetectInStreamSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "DetectInStream", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DetectInStreamResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "DetectInStream", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetectInStreamPreparer prepares the DetectInStream request.
|
||||
func (client GroupClient) DetectInStreamPreparer(imageParameter io.ReadCloser, returnFaceID *bool, returnFaceLandmarks *bool, returnFaceAttributes string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if returnFaceID != nil {
|
||||
queryParameters["returnFaceId"] = autorest.Encode("query", *returnFaceID)
|
||||
}
|
||||
if returnFaceLandmarks != nil {
|
||||
queryParameters["returnFaceLandmarks"] = autorest.Encode("query", *returnFaceLandmarks)
|
||||
}
|
||||
if len(returnFaceAttributes) > 0 {
|
||||
queryParameters["returnFaceAttributes"] = autorest.Encode("query", returnFaceAttributes)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/detect"),
|
||||
autorest.WithFile(imageParameter),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DetectInStreamSender sends the DetectInStream request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client GroupClient) DetectInStreamSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DetectInStreamResponder handles the response to the DetectInStream request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client GroupClient) DetectInStreamResponder(resp *http.Response) (result ListDetectedFace, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// FindSimilar given query face's faceId, find the similar-looking faces from a faceId array or a faceListId.
|
||||
//
|
||||
func (client GroupClient) FindSimilar(body FindSimilarRequest) (result ListSimilarFaceResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.FaceID", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "body.FaceID", Name: validation.MaxLength, Rule: 64, Chain: nil}}},
|
||||
{Target: "body.FaceListID", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.FaceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "body.FaceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil},
|
||||
}},
|
||||
{Target: "body.FaceIds", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 1000, Chain: nil}}},
|
||||
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
|
||||
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "FindSimilar")
|
||||
}
|
||||
|
||||
req, err := client.FindSimilarPreparer(body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "FindSimilar", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.FindSimilarSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "FindSimilar", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.FindSimilarResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "FindSimilar", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FindSimilarPreparer prepares the FindSimilar request.
|
||||
func (client GroupClient) FindSimilarPreparer(body FindSimilarRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/findsimilars"),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// FindSimilarSender sends the FindSimilar request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client GroupClient) FindSimilarSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// FindSimilarResponder handles the response to the FindSimilar request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client GroupClient) FindSimilarResponder(resp *http.Response) (result ListSimilarFaceResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Group divide candidate faces into groups based on face similarity.
|
||||
//
|
||||
func (client GroupClient) Group(body GroupRequest) (result GroupResponse, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.FaceIds", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 1000, Chain: nil}}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Group")
|
||||
}
|
||||
|
||||
req, err := client.GroupPreparer(body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Group", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Group", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Group", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GroupPreparer prepares the Group request.
|
||||
func (client GroupClient) GroupPreparer(body GroupRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/group"),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GroupSender sends the Group request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client GroupClient) GroupSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GroupResponder handles the response to the Group request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client GroupClient) GroupResponder(resp *http.Response) (result GroupResponse, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Identify identify unknown faces from a person group.
|
||||
//
|
||||
func (client GroupClient) Identify(body IdentifyRequest) (result ListIdentifyResultItem, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.PersonGroupID", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "body.FaceIds", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "body.FaceIds", Name: validation.MaxItems, Rule: 1000, Chain: nil}}},
|
||||
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
|
||||
{Target: "body.MaxNumOfCandidatesReturned", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
|
||||
}},
|
||||
{Target: "body.ConfidenceThreshold", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.ConfidenceThreshold", Name: validation.InclusiveMaximum, Rule: 1, Chain: nil},
|
||||
{Target: "body.ConfidenceThreshold", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Identify")
|
||||
}
|
||||
|
||||
req, err := client.IdentifyPreparer(body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Identify", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.IdentifySender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Identify", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.IdentifyResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Identify", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// IdentifyPreparer prepares the Identify request.
|
||||
func (client GroupClient) IdentifyPreparer(body IdentifyRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/identify"),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// IdentifySender sends the Identify request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client GroupClient) IdentifySender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// IdentifyResponder handles the response to the Identify request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client GroupClient) IdentifyResponder(resp *http.Response) (result ListIdentifyResultItem, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Verify verify whether two faces belong to a same person or whether one face belongs to a person.
|
||||
//
|
||||
func (client GroupClient) Verify(body VerifyRequest) (result VerifyResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.FaceID", Name: validation.Null, Rule: true,
|
||||
Chain: []validation.Constraint{{Target: "body.FaceID", Name: validation.MaxLength, Rule: 64, Chain: nil}}},
|
||||
{Target: "body.PersonID", Name: validation.Null, Rule: true, Chain: nil},
|
||||
{Target: "body.PersonGroupID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.GroupClient", "Verify")
|
||||
}
|
||||
|
||||
req, err := client.VerifyPreparer(body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Verify", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.VerifySender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Verify", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.VerifyResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.GroupClient", "Verify", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// VerifyPreparer prepares the Verify request.
|
||||
func (client GroupClient) VerifyPreparer(body VerifyRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/verify"),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// VerifySender sends the Verify request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client GroupClient) VerifySender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// VerifyResponder handles the response to the Verify request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client GroupClient) VerifyResponder(resp *http.Response) (result VerifyResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+608
@@ -0,0 +1,608 @@
|
||||
package face
|
||||
|
||||
// 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"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ListGroupClient is the an API for face detection, verification, and identification.
|
||||
type ListGroupClient struct {
|
||||
ManagementClient
|
||||
}
|
||||
|
||||
// NewListGroupClient creates an instance of the ListGroupClient client.
|
||||
func NewListGroupClient(subscriptionKey string, azureRegion AzureRegions) ListGroupClient {
|
||||
return ListGroupClient{New(subscriptionKey, azureRegion)}
|
||||
}
|
||||
|
||||
// AddFace add a face to a face list. The input face is specified as an image with a targetFace rectangle. It returns a
|
||||
// persistedFaceId representing the added face, and persistedFaceId will not expire.
|
||||
//
|
||||
// faceListID is id referencing a Face List. userData is user-specified data about the face list for any purpose. The
|
||||
// maximum length is 1KB. targetFace is a face rectangle to specify the target face to be added into the face list, in
|
||||
// the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in
|
||||
// the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected
|
||||
// in the entire image.
|
||||
func (client ListGroupClient) AddFace(faceListID string, userData string, targetFace string) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "AddFace")
|
||||
}
|
||||
|
||||
req, err := client.AddFacePreparer(faceListID, userData, targetFace)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFace", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.AddFaceSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFace", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.AddFaceResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFace", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddFacePreparer prepares the AddFace request.
|
||||
func (client ListGroupClient) AddFacePreparer(faceListID string, userData string, targetFace string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if len(userData) > 0 {
|
||||
queryParameters["userData"] = autorest.Encode("query", userData)
|
||||
}
|
||||
if len(targetFace) > 0 {
|
||||
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// AddFaceSender sends the AddFace request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) AddFaceSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// AddFaceResponder handles the response to the AddFace request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) AddFaceResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// AddFaceFromStream add a face to a face list. The input face is specified as an image with a targetFace rectangle. It
|
||||
// returns a persistedFaceId representing the added face, and persistedFaceId will not expire.
|
||||
//
|
||||
// faceListID is id referencing a Face List. userData is user-specified data about the face list for any purpose. The
|
||||
// maximum length is 1KB. targetFace is a face rectangle to specify the target face to be added into the face list, in
|
||||
// the format of "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in
|
||||
// the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected
|
||||
// in the entire image.
|
||||
func (client ListGroupClient) AddFaceFromStream(faceListID string, userData string, targetFace string) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "AddFaceFromStream")
|
||||
}
|
||||
|
||||
req, err := client.AddFaceFromStreamPreparer(faceListID, userData, targetFace)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFaceFromStream", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.AddFaceFromStreamSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFaceFromStream", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.AddFaceFromStreamResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "AddFaceFromStream", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddFaceFromStreamPreparer prepares the AddFaceFromStream request.
|
||||
func (client ListGroupClient) AddFaceFromStreamPreparer(faceListID string, userData string, targetFace string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if len(userData) > 0 {
|
||||
queryParameters["userData"] = autorest.Encode("query", userData)
|
||||
}
|
||||
if len(targetFace) > 0 {
|
||||
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) AddFaceFromStreamResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Create create an empty face list. Up to 64 face lists are allowed to exist in one subscription.
|
||||
//
|
||||
// faceListID is id referencing a particular face list.
|
||||
func (client ListGroupClient) Create(faceListID string, body CreateFaceListRequest) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}},
|
||||
{Target: "body.UserData", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Create")
|
||||
}
|
||||
|
||||
req, err := client.CreatePreparer(faceListID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Create", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.CreateSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Create", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Create", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreatePreparer prepares the Create request.
|
||||
func (client ListGroupClient) CreatePreparer(faceListID string, body CreateFaceListRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPut(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// CreateSender sends the Create request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) CreateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// CreateResponder handles the response to the Create request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Delete delete an existing face list according to faceListId. Persisted face images in the face list will also be
|
||||
// deleted.
|
||||
//
|
||||
// faceListID is id referencing a Face List.
|
||||
func (client ListGroupClient) Delete(faceListID string) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Delete")
|
||||
}
|
||||
|
||||
req, err := client.DeletePreparer(faceListID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Delete", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client ListGroupClient) DeletePreparer(faceListID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteFace delete an existing face from a face list (given by a persisitedFaceId and a faceListId). Persisted image
|
||||
// related to the face will also be deleted.
|
||||
//
|
||||
// faceListID is faceListId of an existing face list. persistedFaceID is persistedFaceId of an existing face.
|
||||
func (client ListGroupClient) DeleteFace(faceListID string, persistedFaceID string) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "DeleteFace")
|
||||
}
|
||||
|
||||
req, err := client.DeleteFacePreparer(faceListID, persistedFaceID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "DeleteFace", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteFaceSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "DeleteFace", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteFaceResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "DeleteFace", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteFacePreparer prepares the DeleteFace request.
|
||||
func (client ListGroupClient) DeleteFacePreparer(faceListID string, persistedFaceID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
"persistedFaceId": autorest.Encode("path", persistedFaceID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}/persistedFaces/{persistedFaceId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteFaceSender sends the DeleteFace request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) DeleteFaceSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteFaceResponder handles the response to the DeleteFace request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) DeleteFaceResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieve a face list's information.
|
||||
//
|
||||
// faceListID is id referencing a Face List.
|
||||
func (client ListGroupClient) Get(faceListID string) (result GetFaceListResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Get")
|
||||
}
|
||||
|
||||
req, err := client.GetPreparer(faceListID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Get", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Get", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client ListGroupClient) GetPreparer(faceListID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) GetResponder(resp *http.Response) (result GetFaceListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// List retrieve information about all existing face lists. Only faceListId, name and userData will be returned.
|
||||
func (client ListGroupClient) List() (result ListGetFaceListResult, err error) {
|
||||
req, err := client.ListPreparer()
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client ListGroupClient) ListPreparer() (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/facelists"),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) ListResponder(resp *http.Response) (result ListGetFaceListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Update update information of a face list.
|
||||
//
|
||||
// faceListID is id referencing a Face List.
|
||||
func (client ListGroupClient) Update(faceListID string, body CreateFaceListRequest) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: faceListID,
|
||||
Constraints: []validation.Constraint{{Target: "faceListID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "faceListID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.ListGroupClient", "Update")
|
||||
}
|
||||
|
||||
req, err := client.UpdatePreparer(faceListID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Update", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.ListGroupClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client ListGroupClient) UpdatePreparer(faceListID string, body CreateFaceListRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"faceListId": autorest.Encode("path", faceListID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/facelists/{faceListId}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ListGroupClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ListGroupClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+360
@@ -0,0 +1,360 @@
|
||||
package face
|
||||
|
||||
// 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"
|
||||
"github.com/Azure/go-autorest/autorest/date"
|
||||
)
|
||||
|
||||
// AzureRegions enumerates the values for azure regions.
|
||||
type AzureRegions string
|
||||
|
||||
const (
|
||||
// Eastus2 specifies the eastus 2 state for azure regions.
|
||||
Eastus2 AzureRegions = "eastus2"
|
||||
// Southeastasia specifies the southeastasia state for azure regions.
|
||||
Southeastasia AzureRegions = "southeastasia"
|
||||
// Westcentralus specifies the westcentralus state for azure regions.
|
||||
Westcentralus AzureRegions = "westcentralus"
|
||||
// Westeurope specifies the westeurope state for azure regions.
|
||||
Westeurope AzureRegions = "westeurope"
|
||||
// Westus specifies the westus state for azure regions.
|
||||
Westus AzureRegions = "westus"
|
||||
)
|
||||
|
||||
// Gender enumerates the values for gender.
|
||||
type Gender string
|
||||
|
||||
const (
|
||||
// Female specifies the female state for gender.
|
||||
Female Gender = "female"
|
||||
// Male specifies the male state for gender.
|
||||
Male Gender = "male"
|
||||
)
|
||||
|
||||
// Glasses enumerates the values for glasses.
|
||||
type Glasses string
|
||||
|
||||
const (
|
||||
// NoGlasses specifies the no glasses state for glasses.
|
||||
NoGlasses Glasses = "noGlasses"
|
||||
// ReadingGlasses specifies the reading glasses state for glasses.
|
||||
ReadingGlasses Glasses = "readingGlasses"
|
||||
// Sunglasses specifies the sunglasses state for glasses.
|
||||
Sunglasses Glasses = "sunglasses"
|
||||
// SwimmingGoggles specifies the swimming goggles state for glasses.
|
||||
SwimmingGoggles Glasses = "swimmingGoggles"
|
||||
)
|
||||
|
||||
// Mode enumerates the values for mode.
|
||||
type Mode string
|
||||
|
||||
const (
|
||||
// MatchFace specifies the match face state for mode.
|
||||
MatchFace Mode = "matchFace"
|
||||
// MatchPerson specifies the match person state for mode.
|
||||
MatchPerson Mode = "matchPerson"
|
||||
)
|
||||
|
||||
// Status enumerates the values for status.
|
||||
type Status string
|
||||
|
||||
const (
|
||||
// Failed specifies the failed state for status.
|
||||
Failed Status = "failed"
|
||||
// Nonstarted specifies the nonstarted state for status.
|
||||
Nonstarted Status = "nonstarted"
|
||||
// Running specifies the running state for status.
|
||||
Running Status = "running"
|
||||
// Succeeded specifies the succeeded state for status.
|
||||
Succeeded Status = "succeeded"
|
||||
)
|
||||
|
||||
// APIError is error information returned by the API
|
||||
type APIError struct {
|
||||
Error *Error `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Attributes is face Attributes
|
||||
type Attributes struct {
|
||||
Age *float64 `json:"age,omitempty"`
|
||||
Gender Gender `json:"gender,omitempty"`
|
||||
Smile *float64 `json:"smile,omitempty"`
|
||||
Glasses Glasses `json:"glasses,omitempty"`
|
||||
FacialHair *FacialHairProperties `json:"facialHair,omitempty"`
|
||||
HeadPose *HeadPoseProperties `json:"headPose,omitempty"`
|
||||
Emotion *EmotionProperties `json:"emotion,omitempty"`
|
||||
}
|
||||
|
||||
// CreateFaceListRequest is request to create a face list.
|
||||
type CreateFaceListRequest struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// CreatePersonGroupRequest is request to create a person group.
|
||||
type CreatePersonGroupRequest struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// CreatePersonRequest is request to create a person object.
|
||||
type CreatePersonRequest struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// CreatePersonResult is result of creating person.
|
||||
type CreatePersonResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
PersonID *string `json:"personId,omitempty"`
|
||||
}
|
||||
|
||||
// DetectedFace is detected Face object.
|
||||
type DetectedFace struct {
|
||||
FaceID *string `json:"faceId,omitempty"`
|
||||
FaceRectangle *Rectangle `json:"faceRectangle,omitempty"`
|
||||
FaceLandmarks *Landmarks `json:"faceLandmarks,omitempty"`
|
||||
}
|
||||
|
||||
// EmotionProperties is properties describing facial emotion.
|
||||
type EmotionProperties struct {
|
||||
Anger *float64 `json:"anger,omitempty"`
|
||||
Contempt *float64 `json:"contempt,omitempty"`
|
||||
Disgust *float64 `json:"disgust,omitempty"`
|
||||
Fear *float64 `json:"fear,omitempty"`
|
||||
Happiness *float64 `json:"happiness,omitempty"`
|
||||
Neutral *float64 `json:"neutral,omitempty"`
|
||||
Sadness *float64 `json:"sadness,omitempty"`
|
||||
Surprise *float64 `json:"surprise,omitempty"`
|
||||
}
|
||||
|
||||
// Error is error body.
|
||||
type Error struct {
|
||||
Code *string `json:"code,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// FacialHairProperties is properties describing facial hair attributes.
|
||||
type FacialHairProperties struct {
|
||||
Mustache *float64 `json:"mustache,omitempty"`
|
||||
Beard *float64 `json:"beard,omitempty"`
|
||||
Sideburns *float64 `json:"sideburns,omitempty"`
|
||||
}
|
||||
|
||||
// FindSimilarRequest is request body for find similar operation.
|
||||
type FindSimilarRequest struct {
|
||||
FaceID *string `json:"faceId,omitempty"`
|
||||
FaceListID *string `json:"faceListId,omitempty"`
|
||||
FaceIds *[]string `json:"faceIds,omitempty"`
|
||||
MaxNumOfCandidatesReturned *int32 `json:"maxNumOfCandidatesReturned,omitempty"`
|
||||
Mode Mode `json:"mode,omitempty"`
|
||||
}
|
||||
|
||||
// GetFaceListResult is result of the GetFaceList operation.
|
||||
type GetFaceListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
FaceListID *string `json:"faceListId,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// GroupRequest is request body for group request.
|
||||
type GroupRequest struct {
|
||||
FaceIds *[]string `json:"faceIds,omitempty"`
|
||||
}
|
||||
|
||||
// GroupResponse is an array of face groups based on face similarity.
|
||||
type GroupResponse struct {
|
||||
autorest.Response `json:"-"`
|
||||
Groups *[][]string `json:"groups,omitempty"`
|
||||
MessyGroup *[]string `json:"messyGroup,omitempty"`
|
||||
}
|
||||
|
||||
// HeadPoseProperties is properties indicating head pose of the face.
|
||||
type HeadPoseProperties struct {
|
||||
Roll *float64 `json:"roll,omitempty"`
|
||||
Yaw *float64 `json:"yaw,omitempty"`
|
||||
Pitch *float64 `json:"pitch,omitempty"`
|
||||
}
|
||||
|
||||
// IdentifyRequest is request body for identify face operation.
|
||||
type IdentifyRequest struct {
|
||||
PersonGroupID *string `json:"personGroupId,omitempty"`
|
||||
FaceIds *[]string `json:"faceIds,omitempty"`
|
||||
MaxNumOfCandidatesReturned *int32 `json:"maxNumOfCandidatesReturned,omitempty"`
|
||||
ConfidenceThreshold *float64 `json:"confidenceThreshold,omitempty"`
|
||||
}
|
||||
|
||||
// IdentifyResultCandidate is all possible faces that may qualify.
|
||||
type IdentifyResultCandidate struct {
|
||||
PersonID *string `json:"personId,omitempty"`
|
||||
Confidence *float64 `json:"confidence,omitempty"`
|
||||
}
|
||||
|
||||
// IdentifyResultItem is response body for identify face operation.
|
||||
type IdentifyResultItem struct {
|
||||
FaceID *string `json:"faceId,omitempty"`
|
||||
Candidates *[]IdentifyResultCandidate `json:"candidates,omitempty"`
|
||||
}
|
||||
|
||||
// ImageURL is
|
||||
type ImageURL struct {
|
||||
URL *string `json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// Landmarks is a collection of 27-point face landmarks pointing to the important positions of face components.
|
||||
type Landmarks struct {
|
||||
PupilLeft *Position `json:"pupilLeft,omitempty"`
|
||||
PupilRight *Position `json:"pupilRight,omitempty"`
|
||||
NoseTip *Position `json:"noseTip,omitempty"`
|
||||
MouthLeft *Position `json:"mouthLeft,omitempty"`
|
||||
MouthRight *Position `json:"mouthRight,omitempty"`
|
||||
EyebrowLeftOuter *Position `json:"eyebrowLeftOuter,omitempty"`
|
||||
EyebrowLeftInner *Position `json:"eyebrowLeftInner,omitempty"`
|
||||
EyeLeftOuter *Position `json:"eyeLeftOuter,omitempty"`
|
||||
EyeLeftTop *Position `json:"eyeLeftTop,omitempty"`
|
||||
EyeLeftBottom *Position `json:"eyeLeftBottom,omitempty"`
|
||||
EyeLeftInner *Position `json:"eyeLeftInner,omitempty"`
|
||||
EyebrowRightInner *Position `json:"eyebrowRightInner,omitempty"`
|
||||
EyebrowRightOuter *Position `json:"eyebrowRightOuter,omitempty"`
|
||||
EyeRightInner *Position `json:"eyeRightInner,omitempty"`
|
||||
EyeRightTop *Position `json:"eyeRightTop,omitempty"`
|
||||
EyeRightBottom *Position `json:"eyeRightBottom,omitempty"`
|
||||
EyeRightOuter *Position `json:"eyeRightOuter,omitempty"`
|
||||
NoseRootLeft *Position `json:"noseRootLeft,omitempty"`
|
||||
NoseRootRight *Position `json:"noseRootRight,omitempty"`
|
||||
NoseLeftAlarTop *Position `json:"noseLeftAlarTop,omitempty"`
|
||||
NoseRightAlarTop *Position `json:"noseRightAlarTop,omitempty"`
|
||||
NoseLeftAlarOutTip *Position `json:"noseLeftAlarOutTip,omitempty"`
|
||||
NoseRightAlarOutTip *Position `json:"noseRightAlarOutTip,omitempty"`
|
||||
UpperLipTop *Position `json:"upperLipTop,omitempty"`
|
||||
UpperLipBottom *Position `json:"upperLipBottom,omitempty"`
|
||||
UnderLipTop *Position `json:"underLipTop,omitempty"`
|
||||
UnderLipBottom *Position `json:"underLipBottom,omitempty"`
|
||||
}
|
||||
|
||||
// ListDetectedFace is
|
||||
type ListDetectedFace struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]DetectedFace `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ListGetFaceListResult is
|
||||
type ListGetFaceListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]GetFaceListResult `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ListIdentifyResultItem is
|
||||
type ListIdentifyResultItem struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]IdentifyResultItem `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ListPersonGroupResult is
|
||||
type ListPersonGroupResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]PersonGroupResult `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ListPersonResult is
|
||||
type ListPersonResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]PersonResult `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ListSimilarFaceResult is
|
||||
type ListSimilarFaceResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]SimilarFaceResult `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// PersonFaceResult is personFace object.
|
||||
type PersonFaceResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
PersistedFaceID *string `json:"persistedFaceId,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// PersonGroupResult is person group object.
|
||||
type PersonGroupResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
PersonGroupID *string `json:"personGroupId,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// PersonResult is person object.
|
||||
type PersonResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
PersonID *string `json:"personId,omitempty"`
|
||||
PersistedFaceIds *[]string `json:"persistedFaceIds,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// Position is coordinates within an image
|
||||
type Position struct {
|
||||
X *int32 `json:"x,omitempty"`
|
||||
Y *int32 `json:"y,omitempty"`
|
||||
}
|
||||
|
||||
// Rectangle is a rectangle within which a face can be found
|
||||
type Rectangle struct {
|
||||
Width *int32 `json:"width,omitempty"`
|
||||
Height *int32 `json:"height,omitempty"`
|
||||
Left *int32 `json:"left,omitempty"`
|
||||
Top *int32 `json:"top,omitempty"`
|
||||
}
|
||||
|
||||
// SimilarFaceResult is response body for find similar face operation.
|
||||
type SimilarFaceResult struct {
|
||||
FaceID *string `json:"faceId,omitempty"`
|
||||
PersistedFaceID *string `json:"persistedFaceId,omitempty"`
|
||||
Confidence *float64 `json:"confidence,omitempty"`
|
||||
}
|
||||
|
||||
// TrainingStatus is training status object.
|
||||
type TrainingStatus struct {
|
||||
autorest.Response `json:"-"`
|
||||
Status Status `json:"status,omitempty"`
|
||||
Created *date.Time `json:"createdDateTime,omitempty"`
|
||||
LastAction *date.Time `json:"lastActionDateTime,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// UpdatePersonFaceDataRequest is request to update person face data.
|
||||
type UpdatePersonFaceDataRequest struct {
|
||||
UserData *string `json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// VerifyRequest is request body for verify operation.
|
||||
type VerifyRequest struct {
|
||||
FaceID *string `json:"faceId,omitempty"`
|
||||
PersonID *string `json:"personId,omitempty"`
|
||||
PersonGroupID *string `json:"personGroupId,omitempty"`
|
||||
}
|
||||
|
||||
// VerifyResult is result of the verify operation.
|
||||
type VerifyResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
IsIdentical *bool `json:"isIdentical,omitempty"`
|
||||
Confidence *float64 `json:"confidence,omitempty"`
|
||||
}
|
||||
Generated
Vendored
+711
@@ -0,0 +1,711 @@
|
||||
package face
|
||||
|
||||
// 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"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// PersonClient is the an API for face detection, verification, and identification.
|
||||
type PersonClient struct {
|
||||
ManagementClient
|
||||
}
|
||||
|
||||
// NewPersonClient creates an instance of the PersonClient client.
|
||||
func NewPersonClient(subscriptionKey string, azureRegion AzureRegions) PersonClient {
|
||||
return PersonClient{New(subscriptionKey, azureRegion)}
|
||||
}
|
||||
|
||||
// AddFace add a representative face to a person for identification. The input face is specified as an image with a
|
||||
// targetFace rectangle.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is target person that the face
|
||||
// is added to. userData is user-specified data about the target face to add for any purpose. The maximum length is
|
||||
// 1KB. targetFace is a face rectangle to specify the target face to be added to a person in the format of
|
||||
// "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image,
|
||||
// targetFace is required to specify which face to add. No targetFace means there is only one face detected in the
|
||||
// entire image.
|
||||
func (client PersonClient) AddFace(personGroupID string, personID string, userData string, targetFace string) (result autorest.Response, err error) {
|
||||
req, err := client.AddFacePreparer(personGroupID, personID, userData, targetFace)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFace", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.AddFaceSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFace", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.AddFaceResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFace", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddFacePreparer prepares the AddFace request.
|
||||
func (client PersonClient) AddFacePreparer(personGroupID string, personID string, userData string, targetFace string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if len(userData) > 0 {
|
||||
queryParameters["userData"] = autorest.Encode("query", userData)
|
||||
}
|
||||
if len(targetFace) > 0 {
|
||||
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// AddFaceSender sends the AddFace request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) AddFaceSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// AddFaceResponder handles the response to the AddFace request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) AddFaceResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// AddFaceFromStream add a representative face to a person for identification. The input face is specified as an image
|
||||
// with a targetFace rectangle.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is target person that the face
|
||||
// is added to. userData is user-specified data about the target face to add for any purpose. The maximum length is
|
||||
// 1KB. targetFace is a face rectangle to specify the target face to be added to a person, in the format of
|
||||
// "targetFace=left,top,width,height". E.g. "targetFace=10,10,100,100". If there is more than one face in the image,
|
||||
// targetFace is required to specify which face to add. No targetFace means there is only one face detected in the
|
||||
// entire image.
|
||||
func (client PersonClient) AddFaceFromStream(personGroupID string, personID string, userData string, targetFace string) (result autorest.Response, err error) {
|
||||
req, err := client.AddFaceFromStreamPreparer(personGroupID, personID, userData, targetFace)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFaceFromStream", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.AddFaceFromStreamSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFaceFromStream", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.AddFaceFromStreamResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "AddFaceFromStream", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AddFaceFromStreamPreparer prepares the AddFaceFromStream request.
|
||||
func (client PersonClient) AddFaceFromStreamPreparer(personGroupID string, personID string, userData string, targetFace string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if len(userData) > 0 {
|
||||
queryParameters["userData"] = autorest.Encode("query", userData)
|
||||
}
|
||||
if len(targetFace) > 0 {
|
||||
queryParameters["targetFace"] = autorest.Encode("query", targetFace)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// AddFaceFromStreamSender sends the AddFaceFromStream request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) AddFaceFromStreamSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// AddFaceFromStreamResponder handles the response to the AddFaceFromStream request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) AddFaceFromStreamResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Create create a new person in a specified person group.
|
||||
//
|
||||
// personGroupID is specifying the target person group to create the person.
|
||||
func (client PersonClient) Create(personGroupID string, body CreatePersonRequest) (result CreatePersonResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}},
|
||||
{Target: "body.UserData", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.PersonClient", "Create")
|
||||
}
|
||||
|
||||
req, err := client.CreatePreparer(personGroupID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Create", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.CreateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Create", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Create", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreatePreparer prepares the Create request.
|
||||
func (client PersonClient) CreatePreparer(personGroupID string, body CreatePersonRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// CreateSender sends the Create request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) CreateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// CreateResponder handles the response to the Create request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) CreateResponder(resp *http.Response) (result CreatePersonResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete delete an existing person from a person group. Persisted face images of the person will also be deleted.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the person. personID is the target personId to delete.
|
||||
func (client PersonClient) Delete(personGroupID string, personID string) (result autorest.Response, err error) {
|
||||
req, err := client.DeletePreparer(personGroupID, personID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Delete", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client PersonClient) DeletePreparer(personGroupID string, personID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteFace delete a face from a person. Relative image for the persisted face will also be deleted.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is specifying the person that
|
||||
// the target persisted face belong to. persistedFaceID is the persisted face to remove.
|
||||
func (client PersonClient) DeleteFace(personGroupID string, personID string, persistedFaceID string) (result autorest.Response, err error) {
|
||||
req, err := client.DeleteFacePreparer(personGroupID, personID, persistedFaceID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "DeleteFace", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteFaceSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "DeleteFace", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteFaceResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "DeleteFace", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteFacePreparer prepares the DeleteFace request.
|
||||
func (client PersonClient) DeleteFacePreparer(personGroupID string, personID string, persistedFaceID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"persistedFaceId": autorest.Encode("path", persistedFaceID),
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteFaceSender sends the DeleteFace request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) DeleteFaceSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteFaceResponder handles the response to the DeleteFace request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) DeleteFaceResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieve a person's information, including registered persisted faces, name and userData.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is specifying the target person.
|
||||
func (client PersonClient) Get(personGroupID string, personID string) (result PersonResult, err error) {
|
||||
req, err := client.GetPreparer(personGroupID, personID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Get", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Get", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client PersonClient) GetPreparer(personGroupID string, personID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) GetResponder(resp *http.Response) (result PersonResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFace retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging
|
||||
// personGroupId).
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is specifying the target person
|
||||
// that the face belongs to. persistedFaceID is the persistedFaceId of the target persisted face of the person.
|
||||
func (client PersonClient) GetFace(personGroupID string, personID string, persistedFaceID string) (result PersonFaceResult, err error) {
|
||||
req, err := client.GetFacePreparer(personGroupID, personID, persistedFaceID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "GetFace", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetFaceSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "GetFace", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetFaceResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "GetFace", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetFacePreparer prepares the GetFace request.
|
||||
func (client PersonClient) GetFacePreparer(personGroupID string, personID string, persistedFaceID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"persistedFaceId": autorest.Encode("path", persistedFaceID),
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetFaceSender sends the GetFace request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) GetFaceSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetFaceResponder handles the response to the GetFace request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) GetFaceResponder(resp *http.Response) (result PersonFaceResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// List list all persons in a person group, and retrieve person information (including personId, name, userData and
|
||||
// persistedFaceIds of registered faces of the person).
|
||||
//
|
||||
// personGroupID is personGroupId of the target person group.
|
||||
func (client PersonClient) List(personGroupID string) (result ListPersonResult, err error) {
|
||||
req, err := client.ListPreparer(personGroupID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client PersonClient) ListPreparer(personGroupID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) ListResponder(resp *http.Response) (result ListPersonResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Update update name or userData of a person.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is personId of the target
|
||||
// person.
|
||||
func (client PersonClient) Update(personGroupID string, personID string, body CreatePersonRequest) (result autorest.Response, err error) {
|
||||
req, err := client.UpdatePreparer(personGroupID, personID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Update", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client PersonClient) UpdatePreparer(personGroupID string, personID string, body CreatePersonRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateFace update a person persisted face's userData field.
|
||||
//
|
||||
// personGroupID is specifying the person group containing the target person. personID is personId of the target
|
||||
// person. persistedFaceID is persistedFaceId of target face, which is persisted and will not expire.
|
||||
func (client PersonClient) UpdateFace(personGroupID string, personID string, persistedFaceID string, body UpdatePersonFaceDataRequest) (result autorest.Response, err error) {
|
||||
req, err := client.UpdateFacePreparer(personGroupID, personID, persistedFaceID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "UpdateFace", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.UpdateFaceSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "UpdateFace", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateFaceResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonClient", "UpdateFace", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateFacePreparer prepares the UpdateFace request.
|
||||
func (client PersonClient) UpdateFacePreparer(personGroupID string, personID string, persistedFaceID string, body UpdatePersonFaceDataRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"persistedFaceId": autorest.Encode("path", persistedFaceID),
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
"personId": autorest.Encode("path", personID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/persons/{personId}/persistedFaces/{persistedFaceId}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// UpdateFaceSender sends the UpdateFace request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonClient) UpdateFaceSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// UpdateFaceResponder handles the response to the UpdateFace request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonClient) UpdateFaceResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+500
@@ -0,0 +1,500 @@
|
||||
package face
|
||||
|
||||
// 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"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/validation"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// PersonGroupClient is the an API for face detection, verification, and identification.
|
||||
type PersonGroupClient struct {
|
||||
ManagementClient
|
||||
}
|
||||
|
||||
// NewPersonGroupClient creates an instance of the PersonGroupClient client.
|
||||
func NewPersonGroupClient(subscriptionKey string, azureRegion AzureRegions) PersonGroupClient {
|
||||
return PersonGroupClient{New(subscriptionKey, azureRegion)}
|
||||
}
|
||||
|
||||
// Create create a new person group with specified personGroupId, name and user-provided userData.
|
||||
//
|
||||
// personGroupID is user-provided personGroupId as a string.
|
||||
func (client PersonGroupClient) Create(personGroupID string, body CreatePersonGroupRequest) (result autorest.Response, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: personGroupID,
|
||||
Constraints: []validation.Constraint{{Target: "personGroupID", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
||||
{Target: "personGroupID", Name: validation.Pattern, Rule: `^[a-z0-9-_]+$`, Chain: nil}}},
|
||||
{TargetValue: body,
|
||||
Constraints: []validation.Constraint{{Target: "body.Name", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.Name", Name: validation.MaxLength, Rule: 128, Chain: nil}}},
|
||||
{Target: "body.UserData", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "body.UserData", Name: validation.MaxLength, Rule: 16384, Chain: nil}}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.PersonGroupClient", "Create")
|
||||
}
|
||||
|
||||
req, err := client.CreatePreparer(personGroupID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.CreateSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.CreateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Create", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreatePreparer prepares the Create request.
|
||||
func (client PersonGroupClient) CreatePreparer(personGroupID string, body CreatePersonGroupRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPut(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// CreateSender sends the Create request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) CreateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// CreateResponder handles the response to the Create request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Delete delete an existing person group. Persisted face images of all people in the person group will also be
|
||||
// deleted.
|
||||
//
|
||||
// personGroupID is the personGroupId of the person group to be deleted.
|
||||
func (client PersonGroupClient) Delete(personGroupID string) (result autorest.Response, err error) {
|
||||
req, err := client.DeletePreparer(personGroupID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client PersonGroupClient) DeletePreparer(personGroupID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get retrieve the information of a person group, including its name and userData.
|
||||
//
|
||||
// personGroupID is personGroupId of the target person group.
|
||||
func (client PersonGroupClient) Get(personGroupID string) (result PersonGroupResult, err error) {
|
||||
req, err := client.GetPreparer(personGroupID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client PersonGroupClient) GetPreparer(personGroupID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) GetResponder(resp *http.Response) (result PersonGroupResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// GetTrainingStatus retrieve the training status of a person group (completed or ongoing).
|
||||
//
|
||||
// personGroupID is personGroupId of target person group.
|
||||
func (client PersonGroupClient) GetTrainingStatus(personGroupID string) (result TrainingStatus, err error) {
|
||||
req, err := client.GetTrainingStatusPreparer(personGroupID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.GetTrainingStatusSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.GetTrainingStatusResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "GetTrainingStatus", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetTrainingStatusPreparer prepares the GetTrainingStatus request.
|
||||
func (client PersonGroupClient) GetTrainingStatusPreparer(personGroupID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/training", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetTrainingStatusSender sends the GetTrainingStatus request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) GetTrainingStatusSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetTrainingStatusResponder handles the response to the GetTrainingStatus request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) GetTrainingStatusResponder(resp *http.Response) (result TrainingStatus, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// List list person groups and their information.
|
||||
//
|
||||
// start is list person groups from the least personGroupId greater than the "start". top is the number of person
|
||||
// groups to list.
|
||||
func (client PersonGroupClient) List(start string, top *int32) (result ListPersonGroupResult, err error) {
|
||||
if err := validation.Validate([]validation.Validation{
|
||||
{TargetValue: start,
|
||||
Constraints: []validation.Constraint{{Target: "start", Name: validation.MaxLength, Rule: 64, Chain: nil}}},
|
||||
{TargetValue: top,
|
||||
Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
|
||||
Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: 1000, Chain: nil},
|
||||
{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
|
||||
}}}}}); err != nil {
|
||||
return result, validation.NewErrorWithValidationError(err, "face.PersonGroupClient", "List")
|
||||
}
|
||||
|
||||
req, err := client.ListPreparer(start, top)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.ListSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.ListResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "List", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListPreparer prepares the List request.
|
||||
func (client PersonGroupClient) ListPreparer(start string, top *int32) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if len(start) > 0 {
|
||||
queryParameters["start"] = autorest.Encode("query", start)
|
||||
}
|
||||
if top != nil {
|
||||
queryParameters["top"] = autorest.Encode("query", *top)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPath("/persongroups"),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// ListSender sends the List request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) ListSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// ListResponder handles the response to the List request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) ListResponder(resp *http.Response) (result ListPersonGroupResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result.Value),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Train queue a person group training task, the training task may not be started immediately.
|
||||
//
|
||||
// personGroupID is target person group to be trained.
|
||||
func (client PersonGroupClient) Train(personGroupID string) (result autorest.Response, err error) {
|
||||
req, err := client.TrainPreparer(personGroupID)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.TrainSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.TrainResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Train", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// TrainPreparer prepares the Train request.
|
||||
func (client PersonGroupClient) TrainPreparer(personGroupID string) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}/train", pathParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// TrainSender sends the Train request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) TrainSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// TrainResponder handles the response to the Train request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) TrainResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Update update an existing person group's display name and userData. The properties which does not appear in request
|
||||
// body will not be updated.
|
||||
//
|
||||
// personGroupID is personGroupId of the person group to be updated.
|
||||
func (client PersonGroupClient) Update(personGroupID string, body CreatePersonGroupRequest) (result autorest.Response, err error) {
|
||||
req, err := client.UpdatePreparer(personGroupID, body)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "face.PersonGroupClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client PersonGroupClient) UpdatePreparer(personGroupID string, body CreatePersonGroupRequest) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
pathParameters := map[string]interface{}{
|
||||
"personGroupId": autorest.Encode("path", personGroupID),
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/face/v1.0", urlParameters),
|
||||
autorest.WithPathParameters("/persongroups/{personGroupId}", pathParameters),
|
||||
autorest.WithJSON(body),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client PersonGroupClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client PersonGroupClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package face
|
||||
|
||||
// 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/v11.0.0-beta arm-face/1.0"
|
||||
}
|
||||
|
||||
// Version returns the semantic version (see http://semver.org) of the client.
|
||||
func Version() string {
|
||||
return "v11.0.0-beta"
|
||||
}
|
||||
Generated
Vendored
+249
@@ -0,0 +1,249 @@
|
||||
// Package textanalytics implements the Azure ARM Textanalytics service API version v2.0.
|
||||
//
|
||||
// The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning
|
||||
// algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase
|
||||
// extraction and language detection. No training data is needed to use this API; just bring your text data. This API
|
||||
// uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can
|
||||
// be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview
|
||||
package textanalytics
|
||||
|
||||
// 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"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const ()
|
||||
|
||||
// ManagementClient is the base client for Textanalytics.
|
||||
type ManagementClient struct {
|
||||
autorest.Client
|
||||
SubscriptionKey string
|
||||
AzureRegion AzureRegions
|
||||
}
|
||||
|
||||
// New creates an instance of the ManagementClient client.
|
||||
func New(subscriptionKey string, azureRegion AzureRegions) ManagementClient {
|
||||
return NewWithoutDefaults(subscriptionKey, azureRegion)
|
||||
}
|
||||
|
||||
// NewWithoutDefaults creates an instance of the ManagementClient client.
|
||||
func NewWithoutDefaults(subscriptionKey string, azureRegion AzureRegions) ManagementClient {
|
||||
return ManagementClient{
|
||||
Client: autorest.NewClientWithUserAgent(UserAgent()),
|
||||
SubscriptionKey: subscriptionKey,
|
||||
AzureRegion: azureRegion,
|
||||
}
|
||||
}
|
||||
|
||||
// DetectLanguage scores close to 1 indicate 100% certainty that the identified language is true. A total of 120
|
||||
// languages are supported.
|
||||
//
|
||||
// input is collection of documents to analyze. numberOfLanguagesToDetect is (Optional. Deprecated) Number of languages
|
||||
// to detect. Set to 1 by default. Irrespective of the value, the language with the highest score is returned.
|
||||
func (client ManagementClient) DetectLanguage(input BatchInput, numberOfLanguagesToDetect *int32) (result LanguageBatchResult, err error) {
|
||||
req, err := client.DetectLanguagePreparer(input, numberOfLanguagesToDetect)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "DetectLanguage", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.DetectLanguageSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "DetectLanguage", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.DetectLanguageResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "DetectLanguage", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DetectLanguagePreparer prepares the DetectLanguage request.
|
||||
func (client ManagementClient) DetectLanguagePreparer(input BatchInput, numberOfLanguagesToDetect *int32) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{}
|
||||
if numberOfLanguagesToDetect != nil {
|
||||
queryParameters["numberOfLanguagesToDetect"] = autorest.Encode("query", *numberOfLanguagesToDetect)
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/text/analytics", urlParameters),
|
||||
autorest.WithPath("/v2.0/languages"),
|
||||
autorest.WithJSON(input),
|
||||
autorest.WithQueryParameters(queryParameters),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DetectLanguageSender sends the DetectLanguage request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ManagementClient) DetectLanguageSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DetectLanguageResponder handles the response to the DetectLanguage request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ManagementClient) DetectLanguageResponder(resp *http.Response) (result LanguageBatchResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// KeyPhrases we employ techniques from Microsoft Office's sophisticated Natural Language Processing toolkit. See the
|
||||
// <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text
|
||||
// Analytics Documentation</a> for details about the languages that are supported by key phrase extraction.
|
||||
//
|
||||
// input is collection of documents to analyze. Documents can now contain a language field to indicate the text
|
||||
// language
|
||||
func (client ManagementClient) KeyPhrases(input MultiLanguageBatchInput) (result KeyPhraseBatchResult, err error) {
|
||||
req, err := client.KeyPhrasesPreparer(input)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "KeyPhrases", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.KeyPhrasesSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "KeyPhrases", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.KeyPhrasesResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "KeyPhrases", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// KeyPhrasesPreparer prepares the KeyPhrases request.
|
||||
func (client ManagementClient) KeyPhrasesPreparer(input MultiLanguageBatchInput) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/text/analytics", urlParameters),
|
||||
autorest.WithPath("/v2.0/keyPhrases"),
|
||||
autorest.WithJSON(input),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// KeyPhrasesSender sends the KeyPhrases request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ManagementClient) KeyPhrasesSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// KeyPhrasesResponder handles the response to the KeyPhrases request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ManagementClient) KeyPhrasesResponder(resp *http.Response) (result KeyPhraseBatchResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Sentiment scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment.
|
||||
// Sentiment score is generated using classification techniques. The input features to the classifier include n-grams,
|
||||
// features generated from part-of-speech tags, and word embeddings. See the <a
|
||||
// href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text
|
||||
// Analytics Documentation</a> for details about the languages that are supported by sentiment analysis.
|
||||
//
|
||||
// input is collection of documents to analyze.
|
||||
func (client ManagementClient) Sentiment(input MultiLanguageBatchInput) (result SentimentBatchResult, err error) {
|
||||
req, err := client.SentimentPreparer(input)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "Sentiment", nil, "Failure preparing request")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := client.SentimentSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "Sentiment", resp, "Failure sending request")
|
||||
return
|
||||
}
|
||||
|
||||
result, err = client.SentimentResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "textanalytics.ManagementClient", "Sentiment", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// SentimentPreparer prepares the Sentiment request.
|
||||
func (client ManagementClient) SentimentPreparer(input MultiLanguageBatchInput) (*http.Request, error) {
|
||||
urlParameters := map[string]interface{}{
|
||||
"AzureRegion": client.AzureRegion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/text/analytics", urlParameters),
|
||||
autorest.WithPath("/v2.0/sentiment"),
|
||||
autorest.WithJSON(input),
|
||||
autorest.WithHeader("Ocp-Apim-Subscription-Key", client.SubscriptionKey))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// SentimentSender sends the Sentiment request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ManagementClient) SentimentSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// SentimentResponder handles the response to the Sentiment request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ManagementClient) SentimentResponder(resp *http.Response) (result SentimentBatchResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
Generated
Vendored
+128
@@ -0,0 +1,128 @@
|
||||
package textanalytics
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// AzureRegions enumerates the values for azure regions.
|
||||
type AzureRegions string
|
||||
|
||||
const (
|
||||
// Eastus2 specifies the eastus 2 state for azure regions.
|
||||
Eastus2 AzureRegions = "eastus2"
|
||||
// Southeastasia specifies the southeastasia state for azure regions.
|
||||
Southeastasia AzureRegions = "southeastasia"
|
||||
// Westcentralus specifies the westcentralus state for azure regions.
|
||||
Westcentralus AzureRegions = "westcentralus"
|
||||
// Westeurope specifies the westeurope state for azure regions.
|
||||
Westeurope AzureRegions = "westeurope"
|
||||
// Westus specifies the westus state for azure regions.
|
||||
Westus AzureRegions = "westus"
|
||||
)
|
||||
|
||||
// BatchInput is
|
||||
type BatchInput struct {
|
||||
Documents *[]Input `json:"documents,omitempty"`
|
||||
}
|
||||
|
||||
// DetectedLanguage is
|
||||
type DetectedLanguage struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Iso6391Name *string `json:"iso6391Name,omitempty"`
|
||||
Score *float64 `json:"score,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorRecord is
|
||||
type ErrorRecord struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorResponse is
|
||||
type ErrorResponse struct {
|
||||
Code *string `json:"code,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
Target *string `json:"target,omitempty"`
|
||||
InnerError *InternalError `json:"innerError,omitempty"`
|
||||
}
|
||||
|
||||
// Input is
|
||||
type Input struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Text *string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
// InternalError is
|
||||
type InternalError struct {
|
||||
Code *string `json:"code,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
InnerError *InternalError `json:"innerError,omitempty"`
|
||||
}
|
||||
|
||||
// KeyPhraseBatchResult is
|
||||
type KeyPhraseBatchResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Documents *[]KeyPhraseBatchResultItem `json:"documents,omitempty"`
|
||||
Errors *[]ErrorRecord `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
// KeyPhraseBatchResultItem is
|
||||
type KeyPhraseBatchResultItem struct {
|
||||
KeyPhrases *[]string `json:"keyPhrases,omitempty"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
// LanguageBatchResult is
|
||||
type LanguageBatchResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Documents *[]LanguageBatchResultItem `json:"documents,omitempty"`
|
||||
Errors *[]ErrorRecord `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
// LanguageBatchResultItem is
|
||||
type LanguageBatchResultItem struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
DetectedLanguages *[]DetectedLanguage `json:"detectedLanguages,omitempty"`
|
||||
}
|
||||
|
||||
// MultiLanguageBatchInput is
|
||||
type MultiLanguageBatchInput struct {
|
||||
Documents *[]MultiLanguageInput `json:"documents,omitempty"`
|
||||
}
|
||||
|
||||
// MultiLanguageInput is
|
||||
type MultiLanguageInput struct {
|
||||
Language *string `json:"language,omitempty"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Text *string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
// SentimentBatchResult is
|
||||
type SentimentBatchResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Documents *[]SentimentBatchResultItem `json:"documents,omitempty"`
|
||||
Errors *[]ErrorRecord `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
// SentimentBatchResultItem is
|
||||
type SentimentBatchResultItem struct {
|
||||
Score *float64 `json:"score,omitempty"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
package textanalytics
|
||||
|
||||
// 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/v11.0.0-beta arm-textanalytics/v2.0"
|
||||
}
|
||||
|
||||
// Version returns the semantic version (see http://semver.org) of the client.
|
||||
func Version() string {
|
||||
return "v11.0.0-beta"
|
||||
}
|
||||
+2698
-262
File diff suppressed because it is too large
Load Diff
+338
-56
@@ -14,9 +14,8 @@ package keyvault
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
// 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"
|
||||
@@ -35,16 +34,30 @@ const (
|
||||
EmailContacts ActionType = "EmailContacts"
|
||||
)
|
||||
|
||||
// JSONWebKeyEncryptionAlgorithm enumerates the values for json web key
|
||||
// encryption algorithm.
|
||||
// DeletionRecoveryLevel enumerates the values for deletion recovery level.
|
||||
type DeletionRecoveryLevel string
|
||||
|
||||
const (
|
||||
// Purgeable specifies the purgeable state for deletion recovery level.
|
||||
Purgeable DeletionRecoveryLevel = "Purgeable"
|
||||
// Recoverable specifies the recoverable state for deletion recovery level.
|
||||
Recoverable DeletionRecoveryLevel = "Recoverable"
|
||||
// RecoverableProtectedSubscription specifies the recoverable protected subscription state for deletion recovery level.
|
||||
RecoverableProtectedSubscription DeletionRecoveryLevel = "Recoverable+ProtectedSubscription"
|
||||
// RecoverablePurgeable specifies the recoverable purgeable state for deletion recovery level.
|
||||
RecoverablePurgeable DeletionRecoveryLevel = "Recoverable+Purgeable"
|
||||
)
|
||||
|
||||
// JSONWebKeyEncryptionAlgorithm enumerates the values for json web key encryption algorithm.
|
||||
type JSONWebKeyEncryptionAlgorithm string
|
||||
|
||||
const (
|
||||
// RSA15 specifies the rsa15 state for json web key encryption algorithm.
|
||||
RSA15 JSONWebKeyEncryptionAlgorithm = "RSA1_5"
|
||||
// RSAOAEP specifies the rsaoaep state for json web key encryption
|
||||
// algorithm.
|
||||
// RSAOAEP specifies the rsaoaep state for json web key encryption algorithm.
|
||||
RSAOAEP JSONWebKeyEncryptionAlgorithm = "RSA-OAEP"
|
||||
// RSAOAEP256 specifies the rsaoaep256 state for json web key encryption algorithm.
|
||||
RSAOAEP256 JSONWebKeyEncryptionAlgorithm = "RSA-OAEP-256"
|
||||
)
|
||||
|
||||
// JSONWebKeyOperation enumerates the values for json web key operation.
|
||||
@@ -65,11 +78,16 @@ const (
|
||||
WrapKey JSONWebKeyOperation = "wrapKey"
|
||||
)
|
||||
|
||||
// JSONWebKeySignatureAlgorithm enumerates the values for json web key
|
||||
// signature algorithm.
|
||||
// JSONWebKeySignatureAlgorithm enumerates the values for json web key signature algorithm.
|
||||
type JSONWebKeySignatureAlgorithm string
|
||||
|
||||
const (
|
||||
// PS256 specifies the ps256 state for json web key signature algorithm.
|
||||
PS256 JSONWebKeySignatureAlgorithm = "PS256"
|
||||
// PS384 specifies the ps384 state for json web key signature algorithm.
|
||||
PS384 JSONWebKeySignatureAlgorithm = "PS384"
|
||||
// PS512 specifies the ps512 state for json web key signature algorithm.
|
||||
PS512 JSONWebKeySignatureAlgorithm = "PS512"
|
||||
// RS256 specifies the rs256 state for json web key signature algorithm.
|
||||
RS256 JSONWebKeySignatureAlgorithm = "RS256"
|
||||
// RS384 specifies the rs384 state for json web key signature algorithm.
|
||||
@@ -100,13 +118,11 @@ type KeyUsageType string
|
||||
const (
|
||||
// CRLSign specifies the crl sign state for key usage type.
|
||||
CRLSign KeyUsageType = "cRLSign"
|
||||
// DataEncipherment specifies the data encipherment state for key usage
|
||||
// type.
|
||||
// DataEncipherment specifies the data encipherment state for key usage type.
|
||||
DataEncipherment KeyUsageType = "dataEncipherment"
|
||||
// DecipherOnly specifies the decipher only state for key usage type.
|
||||
DecipherOnly KeyUsageType = "decipherOnly"
|
||||
// DigitalSignature specifies the digital signature state for key usage
|
||||
// type.
|
||||
// DigitalSignature specifies the digital signature state for key usage type.
|
||||
DigitalSignature KeyUsageType = "digitalSignature"
|
||||
// EncipherOnly specifies the encipher only state for key usage type.
|
||||
EncipherOnly KeyUsageType = "encipherOnly"
|
||||
@@ -125,8 +141,7 @@ type Action struct {
|
||||
ActionType ActionType `json:"action_type,omitempty"`
|
||||
}
|
||||
|
||||
// AdministratorDetails is details of the organization administrator of the
|
||||
// certificate issuer.
|
||||
// AdministratorDetails is details of the organization administrator of the certificate issuer.
|
||||
type AdministratorDetails struct {
|
||||
FirstName *string `json:"first_name,omitempty"`
|
||||
LastName *string `json:"last_name,omitempty"`
|
||||
@@ -149,17 +164,23 @@ type BackupKeyResult struct {
|
||||
Value *string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateAttributes is the certificate management attributes.
|
||||
type CertificateAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
NotBefore *date.UnixTime `json:"nbf,omitempty"`
|
||||
Expires *date.UnixTime `json:"exp,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
// BackupSecretResult is the backup secret result, containing the backup blob.
|
||||
type BackupSecretResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateBundle is a certificate bundle consists of a certificate (X509)
|
||||
// plus its attributes.
|
||||
// CertificateAttributes is the certificate management attributes.
|
||||
type CertificateAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
NotBefore *date.UnixTime `json:"nbf,omitempty"`
|
||||
Expires *date.UnixTime `json:"exp,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
RecoveryLevel DeletionRecoveryLevel `json:"recoveryLevel,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateBundle is a certificate bundle consists of a certificate (X509) plus its attributes.
|
||||
type CertificateBundle struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
@@ -189,8 +210,7 @@ type CertificateImportParameters struct {
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateIssuerItem is the certificate issuer item containing certificate
|
||||
// issuer metadata.
|
||||
// CertificateIssuerItem is the certificate issuer item containing certificate issuer metadata.
|
||||
type CertificateIssuerItem struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Provider *string `json:"provider,omitempty"`
|
||||
@@ -223,8 +243,7 @@ type CertificateIssuerSetParameters struct {
|
||||
Attributes *IssuerAttributes `json:"attributes,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateIssuerUpdateParameters is the certificate issuer update
|
||||
// parameters.
|
||||
// CertificateIssuerUpdateParameters is the certificate issuer update parameters.
|
||||
type CertificateIssuerUpdateParameters struct {
|
||||
Provider *string `json:"provider,omitempty"`
|
||||
Credentials *IssuerCredentials `json:"credentials,omitempty"`
|
||||
@@ -266,8 +285,7 @@ type CertificateMergeParameters struct {
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateOperation is a certificate operation is returned in case of
|
||||
// asynchronous requests.
|
||||
// CertificateOperation is a certificate operation is returned in case of asynchronous requests.
|
||||
type CertificateOperation struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
@@ -281,8 +299,7 @@ type CertificateOperation struct {
|
||||
RequestID *string `json:"request_id,omitempty"`
|
||||
}
|
||||
|
||||
// CertificateOperationUpdateParameter is the certificate operation update
|
||||
// parameters.
|
||||
// CertificateOperationUpdateParameter is the certificate operation update parameters.
|
||||
type CertificateOperationUpdateParameter struct {
|
||||
CancellationRequested *bool `json:"cancellation_requested,omitempty"`
|
||||
}
|
||||
@@ -320,6 +337,143 @@ type Contacts struct {
|
||||
ContactList *[]Contact `json:"contacts,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedCertificateBundle is a Deleted Certificate consisting of its previous id, attributes and its tags, as well as
|
||||
// information on when it will be purged.
|
||||
type DeletedCertificateBundle struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Kid *string `json:"kid,omitempty"`
|
||||
Sid *string `json:"sid,omitempty"`
|
||||
X509Thumbprint *string `json:"x5t,omitempty"`
|
||||
Policy *CertificatePolicy `json:"policy,omitempty"`
|
||||
Cer *[]byte `json:"cer,omitempty"`
|
||||
ContentType *string `json:"contentType,omitempty"`
|
||||
Attributes *CertificateAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
RecoveryID *string `json:"recoveryId,omitempty"`
|
||||
ScheduledPurgeDate *date.UnixTime `json:"scheduledPurgeDate,omitempty"`
|
||||
DeletedDate *date.UnixTime `json:"deletedDate,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedCertificateItem is the deleted certificate item containing metadata about the deleted certificate.
|
||||
type DeletedCertificateItem struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Attributes *CertificateAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
X509Thumbprint *string `json:"x5t,omitempty"`
|
||||
RecoveryID *string `json:"recoveryId,omitempty"`
|
||||
ScheduledPurgeDate *date.UnixTime `json:"scheduledPurgeDate,omitempty"`
|
||||
DeletedDate *date.UnixTime `json:"deletedDate,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedCertificateListResult is a list of certificates that have been deleted in this vault.
|
||||
type DeletedCertificateListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]DeletedCertificateItem `json:"value,omitempty"`
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedCertificateListResultPreparer prepares a request to retrieve the next set of results. It returns
|
||||
// nil if no more results exist.
|
||||
func (client DeletedCertificateListResult) DeletedCertificateListResultPreparer() (*http.Request, error) {
|
||||
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(client.NextLink)))
|
||||
}
|
||||
|
||||
// DeletedKeyBundle is a DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info
|
||||
type DeletedKeyBundle struct {
|
||||
autorest.Response `json:"-"`
|
||||
Key *JSONWebKey `json:"key,omitempty"`
|
||||
Attributes *KeyAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
Managed *bool `json:"managed,omitempty"`
|
||||
RecoveryID *string `json:"recoveryId,omitempty"`
|
||||
ScheduledPurgeDate *date.UnixTime `json:"scheduledPurgeDate,omitempty"`
|
||||
DeletedDate *date.UnixTime `json:"deletedDate,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedKeyItem is the deleted key item containing the deleted key metadata and information about deletion.
|
||||
type DeletedKeyItem struct {
|
||||
Kid *string `json:"kid,omitempty"`
|
||||
Attributes *KeyAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
Managed *bool `json:"managed,omitempty"`
|
||||
RecoveryID *string `json:"recoveryId,omitempty"`
|
||||
ScheduledPurgeDate *date.UnixTime `json:"scheduledPurgeDate,omitempty"`
|
||||
DeletedDate *date.UnixTime `json:"deletedDate,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedKeyListResult is a list of keys that have been deleted in this vault.
|
||||
type DeletedKeyListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]DeletedKeyItem `json:"value,omitempty"`
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedKeyListResultPreparer prepares a request to retrieve the next set of results. It returns
|
||||
// nil if no more results exist.
|
||||
func (client DeletedKeyListResult) DeletedKeyListResultPreparer() (*http.Request, error) {
|
||||
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(client.NextLink)))
|
||||
}
|
||||
|
||||
// DeletedSecretBundle is a Deleted Secret consisting of its previous id, attributes and its tags, as well as
|
||||
// information on when it will be purged.
|
||||
type DeletedSecretBundle struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *string `json:"value,omitempty"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
ContentType *string `json:"contentType,omitempty"`
|
||||
Attributes *SecretAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
Kid *string `json:"kid,omitempty"`
|
||||
Managed *bool `json:"managed,omitempty"`
|
||||
RecoveryID *string `json:"recoveryId,omitempty"`
|
||||
ScheduledPurgeDate *date.UnixTime `json:"scheduledPurgeDate,omitempty"`
|
||||
DeletedDate *date.UnixTime `json:"deletedDate,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedSecretItem is the deleted secret item containing metadata about the deleted secret.
|
||||
type DeletedSecretItem struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Attributes *SecretAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
ContentType *string `json:"contentType,omitempty"`
|
||||
Managed *bool `json:"managed,omitempty"`
|
||||
RecoveryID *string `json:"recoveryId,omitempty"`
|
||||
ScheduledPurgeDate *date.UnixTime `json:"scheduledPurgeDate,omitempty"`
|
||||
DeletedDate *date.UnixTime `json:"deletedDate,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedSecretListResult is the deleted secret list result
|
||||
type DeletedSecretListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]DeletedSecretItem `json:"value,omitempty"`
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
}
|
||||
|
||||
// DeletedSecretListResultPreparer prepares a request to retrieve the next set of results. It returns
|
||||
// nil if no more results exist.
|
||||
func (client DeletedSecretListResult) DeletedSecretListResultPreparer() (*http.Request, error) {
|
||||
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(client.NextLink)))
|
||||
}
|
||||
|
||||
// Error is the key vault server error.
|
||||
type Error struct {
|
||||
Code *string `json:"code,omitempty"`
|
||||
@@ -332,8 +486,7 @@ type ErrorType struct {
|
||||
Error *Error `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// IssuerAttributes is the attributes of an issuer managed by the Key Vault
|
||||
// service.
|
||||
// IssuerAttributes is the attributes of an issuer managed by the Key Vault service.
|
||||
type IssuerAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
@@ -356,15 +509,13 @@ type IssuerCredentials struct {
|
||||
Password *string `json:"pwd,omitempty"`
|
||||
}
|
||||
|
||||
// IssuerParameters is parameters for the issuer of the X509 component of a
|
||||
// certificate.
|
||||
// IssuerParameters is parameters for the issuer of the X509 component of a certificate.
|
||||
type IssuerParameters struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
CertificateType *string `json:"cty,omitempty"`
|
||||
}
|
||||
|
||||
// JSONWebKey is as of
|
||||
// http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18
|
||||
// JSONWebKey is as of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18
|
||||
type JSONWebKey struct {
|
||||
Kid *string `json:"kid,omitempty"`
|
||||
Kty JSONWebKeyType `json:"kty,omitempty"`
|
||||
@@ -383,11 +534,12 @@ type JSONWebKey struct {
|
||||
|
||||
// KeyAttributes is the attributes of a key managed by the key vault service.
|
||||
type KeyAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
NotBefore *date.UnixTime `json:"nbf,omitempty"`
|
||||
Expires *date.UnixTime `json:"exp,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
NotBefore *date.UnixTime `json:"nbf,omitempty"`
|
||||
Expires *date.UnixTime `json:"exp,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
RecoveryLevel DeletionRecoveryLevel `json:"recoveryLevel,omitempty"`
|
||||
}
|
||||
|
||||
// KeyBundle is a KeyBundle consisting of a WebKey plus its attributes.
|
||||
@@ -495,33 +647,89 @@ type KeyVerifyResult struct {
|
||||
Value *bool `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// LifetimeAction is action and its trigger that will be performed by Key Vault
|
||||
// over the lifetime of a certificate.
|
||||
// LifetimeAction is action and its trigger that will be performed by Key Vault over the lifetime of a certificate.
|
||||
type LifetimeAction struct {
|
||||
Trigger *Trigger `json:"trigger,omitempty"`
|
||||
Action *Action `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
// OrganizationDetails is details of the organization of the certificate
|
||||
// issuer.
|
||||
// OrganizationDetails is details of the organization of the certificate issuer.
|
||||
type OrganizationDetails struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
AdminDetails *[]AdministratorDetails `json:"admin_details,omitempty"`
|
||||
}
|
||||
|
||||
// PendingCertificateSigningRequestResult is the pending certificate signing
|
||||
// request result.
|
||||
// PendingCertificateSigningRequestResult is the pending certificate signing request result.
|
||||
type PendingCertificateSigningRequestResult struct {
|
||||
Value *string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// SasDefinitionAttributes is the SAS definition management attributes.
|
||||
type SasDefinitionAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
// SasDefinitionBundle is a SAS definition bundle consists of key vault SAS definition details plus its attributes.
|
||||
type SasDefinitionBundle struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
SecretID *string `json:"sid,omitempty"`
|
||||
Parameters *map[string]*string `json:"parameters,omitempty"`
|
||||
Attributes *SasDefinitionAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// SasDefinitionCreateParameters is the SAS definition create parameters.
|
||||
type SasDefinitionCreateParameters struct {
|
||||
Parameters *map[string]*string `json:"parameters,omitempty"`
|
||||
SasDefinitionAttributes *SasDefinitionAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// SasDefinitionItem is the SAS definition item containing storage SAS definition metadata.
|
||||
type SasDefinitionItem struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
SecretID *string `json:"sid,omitempty"`
|
||||
Attributes *SasDefinitionAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// SasDefinitionListResult is the storage account SAS definition list result.
|
||||
type SasDefinitionListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]SasDefinitionItem `json:"value,omitempty"`
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
}
|
||||
|
||||
// SasDefinitionListResultPreparer prepares a request to retrieve the next set of results. It returns
|
||||
// nil if no more results exist.
|
||||
func (client SasDefinitionListResult) SasDefinitionListResultPreparer() (*http.Request, error) {
|
||||
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(client.NextLink)))
|
||||
}
|
||||
|
||||
// SasDefinitionUpdateParameters is the SAS definition update parameters.
|
||||
type SasDefinitionUpdateParameters struct {
|
||||
Parameters *map[string]*string `json:"parameters,omitempty"`
|
||||
SasDefinitionAttributes *SasDefinitionAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// SecretAttributes is the secret management attributes.
|
||||
type SecretAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
NotBefore *date.UnixTime `json:"nbf,omitempty"`
|
||||
Expires *date.UnixTime `json:"exp,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
NotBefore *date.UnixTime `json:"nbf,omitempty"`
|
||||
Expires *date.UnixTime `json:"exp,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
RecoveryLevel DeletionRecoveryLevel `json:"recoveryLevel,omitempty"`
|
||||
}
|
||||
|
||||
// SecretBundle is a secret consisting of a value, id and its attributes.
|
||||
@@ -569,6 +777,11 @@ type SecretProperties struct {
|
||||
ContentType *string `json:"contentType,omitempty"`
|
||||
}
|
||||
|
||||
// SecretRestoreParameters is the secret restore parameters.
|
||||
type SecretRestoreParameters struct {
|
||||
SecretBundleBackup *string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// SecretSetParameters is the secret set parameters.
|
||||
type SecretSetParameters struct {
|
||||
Value *string `json:"value,omitempty"`
|
||||
@@ -584,6 +797,76 @@ type SecretUpdateParameters struct {
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// StorageAccountAttributes is the storage account management attributes.
|
||||
type StorageAccountAttributes struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
Created *date.UnixTime `json:"created,omitempty"`
|
||||
Updated *date.UnixTime `json:"updated,omitempty"`
|
||||
}
|
||||
|
||||
// StorageAccountCreateParameters is the storage account create parameters.
|
||||
type StorageAccountCreateParameters struct {
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
ActiveKeyName *string `json:"activeKeyName,omitempty"`
|
||||
AutoRegenerateKey *bool `json:"autoRegenerateKey,omitempty"`
|
||||
RegenerationPeriod *string `json:"regenerationPeriod,omitempty"`
|
||||
StorageAccountAttributes *StorageAccountAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// StorageAccountItem is the storage account item containing storage account metadata.
|
||||
type StorageAccountItem struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
Attributes *StorageAccountAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// StorageAccountRegenerteKeyParameters is the storage account key regenerate parameters.
|
||||
type StorageAccountRegenerteKeyParameters struct {
|
||||
KeyName *string `json:"keyName,omitempty"`
|
||||
}
|
||||
|
||||
// StorageAccountUpdateParameters is the storage account update parameters.
|
||||
type StorageAccountUpdateParameters struct {
|
||||
ActiveKeyName *string `json:"activeKeyName,omitempty"`
|
||||
AutoRegenerateKey *bool `json:"autoRegenerateKey,omitempty"`
|
||||
RegenerationPeriod *string `json:"regenerationPeriod,omitempty"`
|
||||
StorageAccountAttributes *StorageAccountAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// StorageBundle is a Storage account bundle consists of key vault storage account details plus its attributes.
|
||||
type StorageBundle struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
ActiveKeyName *string `json:"activeKeyName,omitempty"`
|
||||
AutoRegenerateKey *bool `json:"autoRegenerateKey,omitempty"`
|
||||
RegenerationPeriod *string `json:"regenerationPeriod,omitempty"`
|
||||
Attributes *StorageAccountAttributes `json:"attributes,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// StorageListResult is the storage accounts list result.
|
||||
type StorageListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]StorageAccountItem `json:"value,omitempty"`
|
||||
NextLink *string `json:"nextLink,omitempty"`
|
||||
}
|
||||
|
||||
// StorageListResultPreparer prepares a request to retrieve the next set of results. It returns
|
||||
// nil if no more results exist.
|
||||
func (client StorageListResult) StorageListResultPreparer() (*http.Request, error) {
|
||||
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return autorest.Prepare(&http.Request{},
|
||||
autorest.AsJSON(),
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(to.String(client.NextLink)))
|
||||
}
|
||||
|
||||
// SubjectAlternativeNames is the subject alternate names of a X509 object.
|
||||
type SubjectAlternativeNames struct {
|
||||
Emails *[]string `json:"emails,omitempty"`
|
||||
@@ -597,8 +880,7 @@ type Trigger struct {
|
||||
DaysBeforeExpiry *int32 `json:"days_before_expiry,omitempty"`
|
||||
}
|
||||
|
||||
// X509CertificateProperties is properties of the X509 component of a
|
||||
// certificate.
|
||||
// X509CertificateProperties is properties of the X509 component of a certificate.
|
||||
type X509CertificateProperties struct {
|
||||
Subject *string `json:"subject,omitempty"`
|
||||
Ekus *[]string `json:"ekus,omitempty"`
|
||||
|
||||
+4
-5
@@ -14,16 +14,15 @@ package keyvault
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
// 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/v10.1.0-beta arm-keyvault/2016-10-01"
|
||||
return "Azure-SDK-For-Go/v11.0.0-beta arm-keyvault/2016-10-01"
|
||||
}
|
||||
|
||||
// Version returns the semantic version (see http://semver.org) of the client.
|
||||
func Version() string {
|
||||
return "v10.1.0-beta"
|
||||
return "v11.0.0-beta"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user