Ejemplo n.º 1
0
 def list_manifest_labels(self, manifest, key_prefix=None):
     """ Returns all labels found on the manifest. If specified, the key_prefix will filter the
     labels returned to those keys that start with the given prefix.
 """
     labels = model.label.list_manifest_labels(manifest._db_id,
                                               prefix_filter=key_prefix)
     return [Label.for_label(l) for l in labels]
Ejemplo n.º 2
0
    def delete_manifest_label(self, manifest, label_uuid):
        """
        Delete the label with the specified UUID on the manifest.

        Returns the label deleted or None if none.
        """
        return Label.for_label(oci.label.delete_manifest_label(label_uuid, manifest._db_id))
Ejemplo n.º 3
0
    def create_manifest_label(self,
                              manifest,
                              key,
                              value,
                              source_type_name,
                              media_type_name=None):
        """ Creates a label on the manifest with the given key and value. """
        try:
            tag_manifest = database.TagManifest.get(id=manifest._db_id)
        except database.TagManifest.DoesNotExist:
            return None

        label_data = dict(key=key,
                          value=value,
                          source_type_name=source_type_name,
                          media_type_name=media_type_name)

        with db_transaction():
            # Create the label itself.
            label = model.label.create_manifest_label(tag_manifest, key, value,
                                                      source_type_name,
                                                      media_type_name)

            # Apply any changes to the manifest that the label prescribes.
            apply_label_to_manifest(label_data, manifest, self)

        return Label.for_label(label)
Ejemplo n.º 4
0
    def create_manifest_label(self,
                              manifest,
                              key,
                              value,
                              source_type_name,
                              media_type_name=None):
        """
        Creates a label on the manifest with the given key and value.
        """
        label_data = dict(key=key,
                          value=value,
                          source_type_name=source_type_name,
                          media_type_name=media_type_name)

        # Create the label itself.
        label = oci.label.create_manifest_label(
            manifest._db_id,
            key,
            value,
            source_type_name,
            media_type_name,
        )
        if label is None:
            return None

        # Apply any changes to the manifest that the label prescribes.
        apply_label_to_manifest(label_data, manifest, self)

        return Label.for_label(label)
Ejemplo n.º 5
0
 def get_manifest_label(self, manifest, label_uuid):
     """ Returns the label with the specified UUID on the manifest or None if none. """
     return Label.for_label(
         model.label.get_manifest_label(label_uuid, manifest._db_id))