Example #1
0
def Create(taxonomy_id,
           annotation_name,
           description,
           parent_annotation=None,
           child_annotations=None):
  """Makes an API call to create an annotation in the given taxonomy.

  Args:
    taxonomy_id: Id of a taxonomy.
    annotation_name: Name of the annotation.
    description: a short description to the annotation.
    parent_annotation: Id of the parent annotation to this annotation.
    child_annotations: Ids of child annotations of this annotaiton.

  Returns:
    An Annotation message.
  """
  messages = utils.GetMessagesModule()
  return _GetService().Create(
      messages.DatapolTaxonomyStoresDataTaxonomiesAnnotationsCreateRequest(
          parent=utils.GetTaxonomyRelativeName(taxonomy_id),
          annotation=messages.Annotation(
              displayName=annotation_name,
              description=description,
              parentAnnotation=parent_annotation,
              childAnnotations=child_annotations if child_annotations else [])))
Example #2
0
def Get(taxonomy_name):
  """Makes an API call to get the definition of a taxonomy.

  Args:
    taxonomy_name: Name of the taxonomy.

  Returns:
    A Taxonomy message.
  """
  return _GetService().Get(
      utils.GetMessagesModule().DatapolTaxonomyStoresDataTaxonomiesGetRequest(
          name=utils.GetTaxonomyRelativeName(taxonomy_name)))
Example #3
0
def Delete(taxonomy_name):
  """Makes an API call to delete a taxonomy.

  Args:
    taxonomy_name: Name of the taxonomy.

  Returns:
    An Operation message which can be used to check on the progress of taxonomy
    deletion.
  """
  return _GetService().Delete(utils.GetMessagesModule(
  ).DatapolTaxonomyStoresDataTaxonomiesDeleteRequest(
      name=utils.GetTaxonomyRelativeName(taxonomy_name)))
Example #4
0
def GetIamPolicy(taxonomy_name):
  """Gets IAM policy for a given taxonomy.

  Args:
    taxonomy_name: Name of the taxonomy.

  Returns:
    An IamPolicy message.
  """
  messages = utils.GetMessagesModule()
  return _GetService().GetIamPolicy(
      messages.DatapolTaxonomyStoresDataTaxonomiesGetIamPolicyRequest(
          resource=utils.GetTaxonomyRelativeName(taxonomy_name),
          getIamPolicyRequest=messages.GetIamPolicyRequest()))
Example #5
0
def SetIamPolicy(taxonomy_name, policy):
  """Sets IAM policy, for a given taxonomy.

  Args:
    taxonomy_name: Name of the taxonomy.
    policy: An IamPolicy message.

  Returns:
    An IamPolicy message.
  """
  messages = utils.GetMessagesModule()
  return _GetService().SetIamPolicy(
      messages.DatapolTaxonomyStoresDataTaxonomiesSetIamPolicyRequest(
          resource=utils.GetTaxonomyRelativeName(taxonomy_name),
          setIamPolicyRequest=messages.SetIamPolicyRequest(policy=policy)))
def List(taxonomy_id, limit=None):
    """Makes API calls to list annotations under the given taxonomy.

  Args:
    taxonomy_id: Id of a taxonomy.
    limit: The number of taxonomies to limit the resutls to.

  Returns:
    Generator that yields taxonomies
  """
    request = utils.GetMessagesModule(
    ).DatapolTaxonomyStoresDataTaxonomiesAnnotationsListRequest(
        parent=utils.GetTaxonomyRelativeName(taxonomy_id))
    return list_pager.YieldFromList(_GetService(),
                                    request,
                                    limit=limit,
                                    field='annotations',
                                    batch_size_attribute='pageSize')