class Azure::CognitiveServices::Face::V1_0::PersonGroupOperations

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 PersonGroupOperations class. @param client service class for accessing basic functionality.

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

Private Instance Methods

create(person_group_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil) click to toggle source

Create a new person group with specified personGroupId, name, user-provided userData and recognitionModel. <br /> A person group is the container of the uploaded person data, including face recognition features. <br /> After creation, use [PersonGroup Person - Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523c) to add persons into the group, and then call [PersonGroup - Train](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395249) to get this group ready for [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). <br /> No image will be stored. Only the person's extracted face features and userData will be stored on server until [PersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523d) or [PersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395245) is called. <br/>'recognitionModel' should be specified to associate with this person group. 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 person group will use the recognition model that's already associated with the collection. Existing face features in a person group can't be updated to features extracted by another version of recognition model.

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

Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244). All those person groups 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'.

Person group quota:

  • Free-tier subscription quota: 1,000 person groups. Each holds up to 1,000

persons.

  • S0-tier subscription quota: 1,000,000 person groups. Each holds up to

10,000 persons.

  • to handle larger scale face identification problem, please consider using

[LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 73
def create(person_group_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
  response = create_async(person_group_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
  nil
end
create_async(person_group_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil) click to toggle source

Create a new person group with specified personGroupId, name, user-provided userData and recognitionModel. <br /> A person group is the container of the uploaded person data, including face recognition features. <br /> After creation, use [PersonGroup Person - Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523c) to add persons into the group, and then call [PersonGroup - Train](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395249) to get this group ready for [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). <br /> No image will be stored. Only the person's extracted face features and userData will be stored on server until [PersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523d) or [PersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395245) is called. <br/>'recognitionModel' should be specified to associate with this person group. 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 person group will use the recognition model that's already associated with the collection. Existing face features in a person group can't be updated to features extracted by another version of recognition model.

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

Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244). All those person groups 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'.

Person group quota:

  • Free-tier subscription quota: 1,000 person groups. Each holds up to 1,000

persons.

  • S0-tier subscription quota: 1,000,000 person groups. Each holds up to

10,000 persons.

  • to handle larger scale face identification problem, please consider using

[LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 182
def create_async(person_group_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_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 = 'persongroups/{personGroupId}'

  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: {'personGroupId' => person_group_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 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
create_with_http_info(person_group_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil) click to toggle source

Create a new person group with specified personGroupId, name, user-provided userData and recognitionModel. <br /> A person group is the container of the uploaded person data, including face recognition features. <br /> After creation, use [PersonGroup Person - Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523c) to add persons into the group, and then call [PersonGroup - Train](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395249) to get this group ready for [Face - Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239). <br /> No image will be stored. Only the person's extracted face features and userData will be stored on server until [PersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523d) or [PersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395245) is called. <br/>'recognitionModel' should be specified to associate with this person group. 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 person group will use the recognition model that's already associated with the collection. Existing face features in a person group can't be updated to features extracted by another version of recognition model.

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

Create](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244). All those person groups 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'.

Person group quota:

  • Free-tier subscription quota: 1,000 person groups. Each holds up to 1,000

persons.

  • S0-tier subscription quota: 1,000,000 person groups. Each holds up to

10,000 persons.

  • to handle larger scale face identification problem, please consider using

[LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 128
def create_with_http_info(person_group_id, name:nil, user_data:nil, recognition_model:nil, custom_headers:nil)
  create_async(person_group_id, name:name, user_data:user_data, recognition_model:recognition_model, custom_headers:custom_headers).value!
end
delete(person_group_id, custom_headers:nil) click to toggle source

Delete an existing person group. Persisted face features of all people in the person group will also be deleted.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 251
def delete(person_group_id, custom_headers:nil)
  response = delete_async(person_group_id, custom_headers:custom_headers).value!
  nil
end
delete_async(person_group_id, custom_headers:nil) click to toggle source

Delete an existing person group. Persisted face features of all people in the person group will also be deleted.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 280
def delete_async(person_group_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_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 = 'persongroups/{personGroupId}'

  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: {'personGroupId' => person_group_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_with_http_info(person_group_id, custom_headers:nil) click to toggle source

Delete an existing person group. Persisted face features of all people in the person group will also be deleted.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 266
def delete_with_http_info(person_group_id, custom_headers:nil)
  delete_async(person_group_id, custom_headers:custom_headers).value!
end
get(person_group_id, return_recognition_model:false, custom_headers:nil) click to toggle source

Retrieve person group name, userData and recognitionModel. To get person information under this personGroup, use [PersonGroup Person - List](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395241).

@param person_group_id [String] Id referencing a particular person group. @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 [PersonGroup] operation results.

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

Retrieve person group name, userData and recognitionModel. To get person information under this personGroup, use [PersonGroup Person - List](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395241).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 373
def get_async(person_group_id, return_recognition_model:false, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_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 = 'persongroups/{personGroupId}'

  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: {'personGroupId' => person_group_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::PersonGroup.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_training_status(person_group_id, custom_headers:nil) click to toggle source

Retrieve the training status of a person group (completed or ongoing).

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

@return [TrainingStatus] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/person_group_operations.rb, line 541
def get_training_status(person_group_id, custom_headers:nil)
  response = get_training_status_async(person_group_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_training_status_async(person_group_id, custom_headers:nil) click to toggle source

Retrieve the training status of a person group (completed or ongoing).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 568
def get_training_status_async(person_group_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_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 = 'persongroups/{personGroupId}/training'

  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: {'personGroupId' => person_group_id},
      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::TrainingStatus.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_training_status_with_http_info(person_group_id, custom_headers:nil) click to toggle source

Retrieve the training status of a person group (completed or ongoing).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 555
def get_training_status_with_http_info(person_group_id, custom_headers:nil)
  get_training_status_async(person_group_id, custom_headers:custom_headers).value!
end
get_with_http_info(person_group_id, return_recognition_model:false, custom_headers:nil) click to toggle source

Retrieve person group name, userData and recognitionModel. To get person information under this personGroup, use [PersonGroup Person - List](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395241).

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 356
def get_with_http_info(person_group_id, return_recognition_model:false, custom_headers:nil)
  get_async(person_group_id, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
end
list(start:nil, top:1000, return_recognition_model:false, custom_headers:nil) click to toggle source

List person groups’ personGroupId, name, userData and recognitionModel.<br />

  • Person groups are stored in alphabetical order of personGroupId.

  • “start” parameter (string, optional) is a user-provided personGroupId value

that returned entries have larger ids by string comparison. “start” set to empty to indicate return from the first item.

  • “top” parameter (int, optional) specifies the number of entries to return.

A maximal of 1000 entries can be returned in one call. To fetch more, you can specify “start” with the last returned entry’s Id of the current call. <br /> For example, total 5 person groups: “group1”, …, “group5”. <br /> “start=&top=” will return all 5 groups. <br /> “start=&top=2” will return “group1”, “group2”. <br /> “start=group2&top=3” will return “group3”, “group4”, “group5”.

@param start [String] List person groups from the least personGroupId greater than the “start”. @param top [Integer] The number of person groups to 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 [Array] operation results.

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

List person groups’ personGroupId, name, userData and recognitionModel.<br />

  • Person groups are stored in alphabetical order of personGroupId.

  • “start” parameter (string, optional) is a user-provided personGroupId value

that returned entries have larger ids by string comparison. “start” set to empty to indicate return from the first item.

  • “top” parameter (int, optional) specifies the number of entries to return.

A maximal of 1000 entries can be returned in one call. To fetch more, you can specify “start” with the last returned entry’s Id of the current call. <br /> For example, total 5 person groups: “group1”, …, “group5”. <br /> “start=&top=” will return all 5 groups. <br /> “start=&top=2” will return “group1”, “group2”. <br /> “start=group2&top=3” will return “group3”, “group4”, “group5”.

@param start [String] List person groups from the least personGroupId greater than the “start”. @param top [Integer] The number of person groups to 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/person_group_operations.rb, line 710
def list_async(start:nil, top:1000, return_recognition_model:false, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, "'start' should satisfy the constraint - 'MaxLength': '64'" if !start.nil? && start.length > 64
  fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !top.nil? && top > 1000
  fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1


  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 = 'persongroups'

  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: {'start' => start,'top' => top,'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: 'PersonGroupElementType',
                type: {
                  name: 'Composite',
                  class_name: 'PersonGroup'
                }
            }
          }
        }
        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(start:nil, top:1000, return_recognition_model:false, custom_headers:nil) click to toggle source

List person groups’ personGroupId, name, userData and recognitionModel.<br />

  • Person groups are stored in alphabetical order of personGroupId.

  • “start” parameter (string, optional) is a user-provided personGroupId value

that returned entries have larger ids by string comparison. “start” set to empty to indicate return from the first item.

  • “top” parameter (int, optional) specifies the number of entries to return.

A maximal of 1000 entries can be returned in one call. To fetch more, you can specify “start” with the last returned entry’s Id of the current call. <br /> For example, total 5 person groups: “group1”, …, “group5”. <br /> “start=&top=” will return all 5 groups. <br /> “start=&top=2” will return “group1”, “group2”. <br /> “start=group2&top=3” will return “group3”, “group4”, “group5”.

@param start [String] List person groups from the least personGroupId greater than the “start”. @param top [Integer] The number of person groups to 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/person_group_operations.rb, line 680
def list_with_http_info(start:nil, top:1000, return_recognition_model:false, custom_headers:nil)
  list_async(start:start, top:top, return_recognition_model:return_recognition_model, custom_headers:custom_headers).value!
end
train(person_group_id, custom_headers:nil) click to toggle source

Queue a person group training task, the training task may not be started immediately.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 790
def train(person_group_id, custom_headers:nil)
  response = train_async(person_group_id, custom_headers:custom_headers).value!
  nil
end
train_async(person_group_id, custom_headers:nil) click to toggle source

Queue a person group training task, the training task may not be started immediately.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 819
def train_async(person_group_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_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 = 'persongroups/{personGroupId}/train'

  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: {'personGroupId' => person_group_id},
      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 == 202
      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
train_with_http_info(person_group_id, custom_headers:nil) click to toggle source

Queue a person group training task, the training task may not be started immediately.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 805
def train_with_http_info(person_group_id, custom_headers:nil)
  train_async(person_group_id, custom_headers:custom_headers).value!
end
update(person_group_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 440
def update(person_group_id, name:nil, user_data:nil, custom_headers:nil)
  response = update_async(person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
  nil
end
update_async(person_group_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 473
def update_async(person_group_id, name:nil, user_data:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
  fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_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 = 'persongroups/{personGroupId}'

  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: {'personGroupId' => person_group_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(person_group_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update an existing person group's display name and userData. The properties which does not appear in request body will not be updated.

@param person_group_id [String] Id referencing a particular person group. @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/person_group_operations.rb, line 457
def update_with_http_info(person_group_id, name:nil, user_data:nil, custom_headers:nil)
  update_async(person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
end