@Mitchel Skees ,
Great Question, Seems like model UUID is not stored anywhere in Developer Portal database (MySQL). It’s actually fetched from Apigee API Modelling data store using APIs.
Below code will help you to fetch all models & their UUIDs related to Developer Portal in a custom module.
// Register autoloaders.
drupal_load('module', 'devconnect');
devconnect_init();
$config = devconnect_default_org_config();
if (empty($config->orgName) || empty($config->endpoint)) {
// Edge connection is not configured, so we bail.
}
drupal_load('module', 'smartdocs');
$model = new Apigee\SmartDocs\Model($config);
$model_list = $model->listModels();
foreach ($model_list as $model) {
var modelUUID = $model->getUuid()
}
You have also mentioned that on submission you create a new model, that means you should have model UUID in response of API call / Function that created model. So , I don’t think you even need above code.
Can you post the custom code using which you are creating new model ? That will give us better picture.
Checkout below code which actually creates smartdocs model & you can also see how UUID is retrieved & redirected to some other page that has UUID reference. I am pretty sure you might be using same logic in your custom module.
function smartdocs_add_model_submit(array $form, array &$form_state) {
$model = new Model(devconnect_default_org_config());
$model->setName(trim($form_state['values']['model_name']));
$model->setDisplayName(trim($form_state['values']['display_name']));
$model->setDescription(trim($form_state['values']['model_description']));
$success = FALSE;
try {
$model->save();
// Get the content of the custom template.
$custom_template_file = variable_get('smartdocs_custom_template_file', NULL);
$template_content = FALSE;
if (!empty($custom_template_file)) {
$file = file_load($custom_template_file);
$path = FALSE;
if ($file === FALSE) {
// The custom template file no longer exists in db, show error and
// remove setting.
drupal_set_message(t('Custom model template could not be loaded. Standard model template is being used instead.'), 'warning');
watchdog('smartdocs', 'Custom model template could not be loaded, smartdocs_custom_template_file variable was set to %smartdocs_custom_template_file.', array('%smartdocs_custom_template_file' => $custom_template_file), WATCHDOG_ERROR);
variable_del('smartdocs_custom_template_file');
}
else {
$path = file_create_url($file->uri);
}
// Get custom template content if path is valid.
if ($path) {
$template_content = file_get_contents($path);
if ($template_content === FALSE) {
// The custom template file no longer exists in filesystem, show error
// and remove setting.
drupal_set_message(t('Custom model template could not be loaded. Standard model template is being used instead.'), 'warning');
watchdog('smartdocs', 'Custom model template could not be loaded, could not get contents of file %path.', array('path' => $path), WATCHDOG_ERROR);
variable_del('smartdocs_custom_template_file');
}
}
}
// Check to see if successfully loaded the custom template and if not get
// standard template content to add to model.
if ($template_content === FALSE) {
$path = drupal_get_path('module', 'smartdocs') . '/templates/smartdocs.hbr';
$template_content = file_get_contents($path);
}
$template = new Template(devconnect_default_org_config(), $model->getUuid());
$template->save(SMARTDOCS_TEMPLATE_NAME, 'method', $template_content, TRUE);
$success = TRUE;
module_invoke_all('smartdocs_model_update', $model->getUuid());
$form_state['values']['model_id'] = $model->getUuid();
// Create taxonomy term for model.
$term = taxonomy_get_term_by_name($model->getName(), 'smartdocs_models');
if (empty($term)) {
$vocab = taxonomy_vocabulary_machine_name_load('smartdocs_models');
if (!empty($vocab)) {
$term = new stdClass();
$term->vid = $vocab->vid;
$term->name = $model->getName();
$term->description = $model->getDescription();
$term->field_model_display_name[LANGUAGE_NONE][0]['value'] = $model->getDisplayName();
taxonomy_term_save($term);
}
}
}
catch (Exception $e) {
drupal_set_message(t('There was an error when trying to create the model.'), 'error');
watchdog_exception('smartdocs', $e);
}
if ($success) {
menu_rebuild();
drupal_set_message($model->getDisplayName() . ' was created successfully.', 'status');
$form_state['redirect'] = 'admin/content/smartdocs/models/' . $model->getUuid();
}
}
Check the last few lines in above code that explains same. Hope it helps. Keep us posted.