class Azure::CognitiveServices::Face::V1_0::FaceListOperations

An API for face detection, verification, and identification.

Attributes

client[R]

@return [FaceClient] reference to the FaceClient

Private Class Methods

new(client) click to toggle source

Creates and initializes a new instance of the FaceListOperations class. @param client service class for accessing basic functionality.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 17
def initialize(client)
  @client = client
end

Private Instance Methods

add_face_from_stream(face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) or [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better detection and recognition precision.

Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same face list are processed sequentially

and to/from different face lists are in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param face_list_id [String] Id referencing a particular face list. @param image An image stream. @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] 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. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PersistedFace] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 1062
def add_face_from_stream(face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  response = add_face_from_stream_async(face_list_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
add_face_from_stream_async(face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) or [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better detection and recognition precision.

Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same face list are processed sequentially

and to/from different face lists are in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param face_list_id [String] Id referencing a particular face list. @param image An image stream. @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] 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. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 1197
def add_face_from_stream_async(face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
  fail ArgumentError, 'image is nil' if image.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/octet-stream'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = {
    client_side_validation: true,
    required: true,
    serialized_name: 'Image',
    type: {
      name: 'Stream'
    }
  }
  request_content = @client.serialize(request_mapper,  image)

  path_template = 'facelists/{faceListId}/persistedfaces'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id},
      query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
add_face_from_stream_with_http_info(face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) or [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better detection and recognition precision.

Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same face list are processed sequentially

and to/from different face lists are in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param face_list_id [String] Id referencing a particular face list. @param image An image stream. @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] 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. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 1130
def add_face_from_stream_with_http_info(face_list_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  add_face_from_stream_async(face_list_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
end
add_face_from_url(face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) or [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better detection and recognition precision.

Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same face list are processed sequentially

and to/from different face lists are in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param face_list_id [String] Id referencing a particular face list. @param url [String] Publicly reachable URL of an image @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] 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. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PersistedFace] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 795
def add_face_from_url(face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  response = add_face_from_url_async(face_list_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
add_face_from_url_async(face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) or [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better detection and recognition precision.

Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same face list are processed sequentially

and to/from different face lists are in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param face_list_id [String] Id referencing a particular face list. @param url [String] Publicly reachable URL of an image @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] 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. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 930
def add_face_from_url_async(face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
  fail ArgumentError, 'url is nil' if url.nil?

  image_url = ImageUrl.new
  unless url.nil?
    image_url.url = url
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
  request_content = @client.serialize(request_mapper,  image_url)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'facelists/{faceListId}/persistedfaces'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id},
      query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
add_face_from_url_with_http_info(face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395251) or [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better detection and recognition precision.

Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same face list are processed sequentially

and to/from different face lists are in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param face_list_id [String] Id referencing a particular face list. @param url [String] Publicly reachable URL of an image @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] 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. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 863
def add_face_from_url_with_http_info(face_list_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  add_face_from_url_async(face_list_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
end
create(face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil) click to toggle source

Create an empty face list with user-specified faceListId, name, an optional userData and recognitionModel. Up to 64 face lists are allowed in one subscription. <br /> Face list is a list of faces, up to 1,000 faces, and used by [Face - Find Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). <br /> After creation, user should use [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250) to import the faces. No image will be stored. Only the extracted face features are stored on server until [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Find Similar is used for scenario like finding celebrity-like faces, similar face filtering, or as a light way face identification. But if the actual use is to identify person, please use [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244) / [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d) and [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). <br /> Please consider [LargeFaceList](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) when the face number is large. It can support up to 1,000,000 faces. <br />'recognitionModel' should be specified to associate with this face list. The default value for 'recognitionModel' is 'recognition_01', if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing face list will use the recognition model that's already associated with the collection. Existing face features in a face list can't be updated to features extracted by another version of recognition model.

  • 'recognition_01': The default recognition model for [FaceList-

Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b). All those face lists created before 2019 March are bonded with this recognition model.

  • 'recognition_02': Recognition model released in 2019 March.

'recognition_02' is recommended since its overall accuracy is improved compared with 'recognition_01'.

@param face_list_id [String] Id referencing a particular face list. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param recognition_model [RecognitionModel] Possible values include: 'recognition_01', 'recognition_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 72
def create(face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
  response = create_async(face_list_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
  nil
end
create_async(face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil) click to toggle source

Create an empty face list with user-specified faceListId, name, an optional userData and recognitionModel. Up to 64 face lists are allowed in one subscription. <br /> Face list is a list of faces, up to 1,000 faces, and used by [Face - Find Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). <br /> After creation, user should use [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250) to import the faces. No image will be stored. Only the extracted face features are stored on server until [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Find Similar is used for scenario like finding celebrity-like faces, similar face filtering, or as a light way face identification. But if the actual use is to identify person, please use [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244) / [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d) and [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). <br /> Please consider [LargeFaceList](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) when the face number is large. It can support up to 1,000,000 faces. <br />'recognitionModel' should be specified to associate with this face list. The default value for 'recognitionModel' is 'recognition_01', if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing face list will use the recognition model that's already associated with the collection. Existing face features in a face list can't be updated to features extracted by another version of recognition model.

  • 'recognition_01': The default recognition model for [FaceList-

Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b). All those face lists created before 2019 March are bonded with this recognition model.

  • 'recognition_02': Recognition model released in 2019 March.

'recognition_02' is recommended since its overall accuracy is improved compared with 'recognition_01'.

@param face_list_id [String] Id referencing a particular face list. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param recognition_model [RecognitionModel] Possible values include: 'recognition_01', 'recognition_02' @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 179
def create_async(face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384

  body = MetaDataContract.new
  unless name.nil? && user_data.nil? && recognition_model.nil?
    body.name = name
    body.user_data = user_data
    body.recognition_model = recognition_model
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::MetaDataContract.mapper()
  request_content = @client.serialize(request_mapper,  body)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'facelists/{faceListId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:put, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
create_with_http_info(face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil) click to toggle source

Create an empty face list with user-specified faceListId, name, an optional userData and recognitionModel. Up to 64 face lists are allowed in one subscription. <br /> Face list is a list of faces, up to 1,000 faces, and used by [Face - Find Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237). <br /> After creation, user should use [FaceList - Add Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250) to import the faces. No image will be stored. Only the extracted face features are stored on server until [FaceList - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f) is called. <br /> Find Similar is used for scenario like finding celebrity-like faces, similar face filtering, or as a light way face identification. But if the actual use is to identify person, please use [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244) / [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d) and [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). <br /> Please consider [LargeFaceList](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc) when the face number is large. It can support up to 1,000,000 faces. <br />'recognitionModel' should be specified to associate with this face list. The default value for 'recognitionModel' is 'recognition_01', if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing face list will use the recognition model that's already associated with the collection. Existing face features in a face list can't be updated to features extracted by another version of recognition model.

  • 'recognition_01': The default recognition model for [FaceList-

Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b). All those face lists created before 2019 March are bonded with this recognition model.

  • 'recognition_02': Recognition model released in 2019 March.

'recognition_02' is recommended since its overall accuracy is improved compared with 'recognition_01'.

@param face_list_id [String] Id referencing a particular face list. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param recognition_model [RecognitionModel] Possible values include: 'recognition_01', 'recognition_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 126
def create_with_http_info(face_list_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
  create_async(face_list_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
end
delete(face_list_id, custom_headers:nil) click to toggle source

Delete a specified face list.

@param face_list_id [String] Id referencing a particular face list. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 451
def delete(face_list_id, custom_headers:nil)
  response = delete_async(face_list_id, custom_headers:custom_headers).value!
  nil
end
delete_async(face_list_id, custom_headers:nil) click to toggle source

Delete a specified face list.

@param face_list_id [String] Id referencing a particular face list. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 478
def delete_async(face_list_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'facelists/{faceListId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
delete_face(face_list_id, persisted_face_id, custom_headers:nil) click to toggle source

Delete a face from a face list by specified faceListId and persistedFaceId. <br /> Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel.

@param face_list_id [String] Id referencing a particular face list. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 651
def delete_face(face_list_id, persisted_face_id, custom_headers:nil)
  response = delete_face_async(face_list_id, persisted_face_id, custom_headers:custom_headers).value!
  nil
end
delete_face_async(face_list_id, persisted_face_id, custom_headers:nil) click to toggle source

Delete a face from a face list by specified faceListId and persistedFaceId. <br /> Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel.

@param face_list_id [String] Id referencing a particular face list. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 686
def delete_face_async(face_list_id, persisted_face_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'facelists/{faceListId}/persistedfaces/{persistedFaceId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id,'persistedFaceId' => persisted_face_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
delete_face_with_http_info(face_list_id, persisted_face_id, custom_headers:nil) click to toggle source

Delete a face from a face list by specified faceListId and persistedFaceId. <br /> Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel.

@param face_list_id [String] Id referencing a particular face list. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 669
def delete_face_with_http_info(face_list_id, persisted_face_id, custom_headers:nil)
  delete_face_async(face_list_id, persisted_face_id, custom_headers:custom_headers).value!
end
delete_with_http_info(face_list_id, custom_headers:nil) click to toggle source

Delete a specified face list.

@param face_list_id [String] Id referencing a particular face list. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 465
def delete_with_http_info(face_list_id, custom_headers:nil)
  delete_async(face_list_id, custom_headers:custom_headers).value!
end
get(face_list_id, return_recognition_model:false, custom_headers:nil) click to toggle source

Retrieve a face list’s faceListId, name, userData, recognitionModel and faces in the face list.

@param face_list_id [String] Id referencing a particular face list. @param return_recognition_model [Boolean] A value indicating whether the operation should return 'recognitionModel' in response. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [FaceList] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 252
def get(face_list_id, return_recognition_model:false, custom_headers:nil)
  response = get_async(face_list_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_async(face_list_id, return_recognition_model:false, custom_headers:nil) click to toggle source

Retrieve a face list’s faceListId, name, userData, recognitionModel and faces in the face list.

@param face_list_id [String] Id referencing a particular face list. @param return_recognition_model [Boolean] A value indicating whether the operation should return 'recognitionModel' in response. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 287
def get_async(face_list_id, return_recognition_model:false, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'facelists/{faceListId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id},
      query_params: {'returnRecognitionModel' => return_recognition_model},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::FaceList.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
get_with_http_info(face_list_id, return_recognition_model:false, custom_headers:nil) click to toggle source

Retrieve a face list’s faceListId, name, userData, recognitionModel and faces in the face list.

@param face_list_id [String] Id referencing a particular face list. @param return_recognition_model [Boolean] A value indicating whether the operation should return 'recognitionModel' in response. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 270
def get_with_http_info(face_list_id, return_recognition_model:false, custom_headers:nil)
  get_async(face_list_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
end
list(return_recognition_model:false, custom_headers:nil) click to toggle source

List face lists’ faceListId, name, userData and recognitionModel. <br /> To get face information inside faceList use [FaceList - Get](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524c)

@param return_recognition_model [Boolean] A value indicating whether the operation should return 'recognitionModel' in response. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 536
def list(return_recognition_model:false, custom_headers:nil)
  response = list_async(return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_async(return_recognition_model:false, custom_headers:nil) click to toggle source

List face lists’ faceListId, name, userData and recognitionModel. <br /> To get face information inside faceList use [FaceList - Get](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524c)

@param return_recognition_model [Boolean] A value indicating whether the operation should return 'recognitionModel' in response. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 571
def list_async(return_recognition_model:false, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'facelists'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      query_params: {'returnRecognitionModel' => return_recognition_model},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'FaceListElementType',
                type: {
                  name: 'Composite',
                  class_name: 'FaceList'
                }
            }
          }
        }
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
list_with_http_info(return_recognition_model:false, custom_headers:nil) click to toggle source

List face lists’ faceListId, name, userData and recognitionModel. <br /> To get face information inside faceList use [FaceList - Get](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524c)

@param return_recognition_model [Boolean] A value indicating whether the operation should return 'recognitionModel' in response. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 554
def list_with_http_info(return_recognition_model:false, custom_headers:nil)
  list_async(return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
end
update(face_list_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update information of a face list.

@param face_list_id [String] Id referencing a particular face list. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 353
def update(face_list_id, name:nil, user_data:nil, custom_headers:nil)
  response = update_async(face_list_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
  nil
end
update_async(face_list_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update information of a face list.

@param face_list_id [String] Id referencing a particular face list. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 384
def update_async(face_list_id, name:nil, user_data:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'face_list_id is nil' if face_list_id.nil?
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
  fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384

  body = NameAndUserDataContract.new
  unless name.nil? && user_data.nil?
    body.name = name
    body.user_data = user_data
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
  request_content = @client.serialize(request_mapper,  body)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'facelists/{faceListId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'faceListId' => face_list_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:patch, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
update_with_http_info(face_list_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update information of a face list.

@param face_list_id [String] Id referencing a particular face list. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb, line 369
def update_with_http_info(face_list_id, name:nil, user_data:nil, custom_headers:nil)
  update_async(face_list_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
end