@@ -618,4 +618,169 @@ exports.update_resources_access_mode_by_ids = function update_resources_access_m
618618 var options = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : { } ;
619619
620620 return updateResourcesAccessMode ( access_mode , "public_ids[]" , ids , callback , options ) ;
621+ } ;
622+
623+ /**
624+ * Creates a new metadata field definition
625+ *
626+ * @see https://cloudinary.com/documentation/admin_api#create_a_metadata_field
627+ *
628+ * @param {Object } field The field to add
629+ * @param {Function } callback Callback function
630+ * @param {Object } options Configuration options
631+ *
632+ * @return {Object }
633+ */
634+ exports . add_metadata_field = function add_metadata_field ( field , callback ) {
635+ var options = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
636+
637+ var params = only ( field , "external_id" , "type" , "label" , "mandatory" , "default_value" , "validation" , "datasource" ) ;
638+ options . content_type = "json" ;
639+ return call_api ( "post" , [ "metadata_fields" ] , params , callback , options ) ;
640+ } ;
641+
642+ /**
643+ * Returns a list of all metadata field definitions
644+ *
645+ * @see https://cloudinary.com/documentation/admin_api#get_metadata_fields
646+ *
647+ * @param {Function } callback Callback function
648+ * @param {Object } options Configuration options
649+ *
650+ * @return {Object }
651+ */
652+ exports . list_metadata_fields = function list_metadata_fields ( callback ) {
653+ var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
654+
655+ return call_api ( "get" , [ "metadata_fields" ] , { } , callback , options ) ;
656+ } ;
657+
658+ /**
659+ * Deletes a metadata field definition.
660+ *
661+ * The field should no longer be considered a valid candidate for all other endpoints
662+ *
663+ * @see https://cloudinary.com/documentation/admin_api#delete_a_metadata_field_by_external_id
664+ *
665+ * @param {String } field_external_id The external id of the field to delete
666+ * @param {Function } callback Callback function
667+ * @param {Object } options Configuration options
668+ *
669+ * @return {Object }
670+ */
671+ exports . delete_metadata_field = function delete_metadata_field ( field_external_id , callback ) {
672+ var options = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
673+
674+ return call_api ( "delete" , [ "metadata_fields" , field_external_id ] , { } , callback , options ) ;
675+ } ;
676+
677+ /**
678+ * Get a metadata field by external id
679+ *
680+ * @see https://cloudinary.com/documentation/admin_api#get_a_metadata_field_by_external_id
681+ *
682+ * @param {String } external_id The ID of the metadata field to retrieve
683+ * @param {Function } callback Callback function
684+ * @param {Object } options Configuration options
685+ *
686+ * @return {Object }
687+ */
688+ exports . metadata_field_by_field_id = function metadata_field_by_field_id ( external_id , callback ) {
689+ var options = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
690+
691+ return call_api ( "get" , [ "metadata_fields" , external_id ] , { } , callback , options ) ;
692+ } ;
693+
694+ /**
695+ * Updates a metadata field by external id
696+ *
697+ * Updates a metadata field definition (partially, no need to pass the entire object) passed as JSON data.
698+ * See {@link https://cloudinary.com/documentation/admin_api#generic_structure_of_a_metadata_field Generic structure of a metadata field} for details.
699+ *
700+ * @see https://cloudinary.com/documentation/admin_api#update_a_metadata_field_by_external_id
701+ *
702+ * @param {String } external_id The ID of the metadata field to update
703+ * @param {Object } field Updated values of metadata field
704+ * @param {Function } callback Callback function
705+ * @param {Object } options Configuration options
706+ *
707+ * @return {Object }
708+ */
709+ exports . update_metadata_field = function update_metadata_field ( external_id , field , callback ) {
710+ var options = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : { } ;
711+
712+ var params = only ( field , "external_id" , "type" , "label" , "mandatory" , "default_value" , "validation" , "datasource" ) ;
713+ options . content_type = "json" ;
714+ return call_api ( "put" , [ "metadata_fields" , external_id ] , params , callback , options ) ;
715+ } ;
716+
717+ /**
718+ * Updates a metadata field datasource
719+ *
720+ * Updates the datasource of a supported field type (currently only enum and set), passed as JSON data. The
721+ * update is partial: datasource entries with an existing external_id will be updated and entries with new
722+ * external_id’s (or without external_id’s) will be appended.
723+ *
724+ * @see https://cloudinary.com/documentation/admin_api#update_a_metadata_field_datasource
725+ *
726+ * @param {String } field_external_id The ID of the field to update
727+ * @param {Object } entries_external_id Updated values for datasource
728+ * @param {Function } callback Callback function
729+ * @param {Object } options Configuration options
730+ *
731+ * @return {Object }
732+ */
733+ exports . update_metadata_field_datasource = function update_metadata_field_datasource ( field_external_id , entries_external_id , callback ) {
734+ var options = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : { } ;
735+
736+ var params = only ( entries_external_id , "values" ) ;
737+ options . content_type = "json" ;
738+ return call_api ( "put" , [ "metadata_fields" , field_external_id , "datasource" ] , params , callback , options ) ;
739+ } ;
740+
741+ /**
742+ * Deletes entries in a metadata field datasource
743+ *
744+ * Deletes (blocks) the datasource entries for a specified metadata field definition. Sets the state of the
745+ * entries to inactive. This is a soft delete, the entries still exist under the hood and can be activated again
746+ * with the restore datasource entries method.
747+ *
748+ * @see https://cloudinary.com/documentation/admin_api#delete_entries_in_a_metadata_field_datasource
749+ *
750+ * @param {String } field_external_id The ID of the metadata field
751+ * @param {Array } entries_external_id An array of IDs of datasource entries to delete
752+ * @param {Function } callback Callback function
753+ * @param {Object } options Configuration options
754+ *
755+ * @return {Object }
756+ */
757+ exports . delete_datasource_entries = function delete_datasource_entries ( field_external_id , entries_external_id , callback ) {
758+ var options = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : { } ;
759+
760+ options . content_type = "json" ;
761+ var params = { external_ids : entries_external_id } ;
762+ return call_api ( "delete" , [ "metadata_fields" , field_external_id , "datasource" ] , params , callback , options ) ;
763+ } ;
764+
765+ /**
766+ * Restores entries in a metadata field datasource
767+ *
768+ * Restores (unblocks) any previously deleted datasource entries for a specified metadata field definition.
769+ * Sets the state of the entries to active.
770+ *
771+ * @see https://cloudinary.com/documentation/admin_api#restore_entries_in_a_metadata_field_datasource
772+ *
773+ * @param {String } field_external_id The ID of the metadata field
774+ * @param {Array } entries_external_id An array of IDs of datasource entries to delete
775+ * @param {Function } callback Callback function
776+ * @param {Object } options Configuration options
777+ *
778+ * @return {Object }
779+ */
780+ exports . restore_metadata_field_datasource = function restore_metadata_field_datasource ( field_external_id , entries_external_id , callback ) {
781+ var options = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : { } ;
782+
783+ options . content_type = "json" ;
784+ var params = { external_ids : entries_external_id } ;
785+ return call_api ( "post" , [ "metadata_fields" , field_external_id , "datasource_restore" ] , params , callback , options ) ;
621786} ;
0 commit comments