OvirtCollection *ovirt_sub_collection_new_from_resource_search(OvirtResource *resource, const char *href, const char *collection_name, GType resource_type, const char *resource_name, const char *query) { const char *link; char *substr; gchar *link_query, *escaped_query; OvirtCollection *collection; link = ovirt_resource_get_sub_collection(resource, href); if (link == NULL) return NULL; /* link is will be something like "/ovirt-engine/api/vms?search={query}", so * we need to strip out {query} substring. */ substr = g_strrstr(link, "{query}"); if (substr != NULL) *substr = '\0'; escaped_query = g_uri_escape_string(query, NULL, FALSE); link_query = g_strconcat(link, escaped_query, NULL); collection = ovirt_collection_new(link_query, collection_name, resource_type, resource_name); g_free(escaped_query); g_free(link_query); return collection; }
OvirtCollection *ovirt_sub_collection_new_from_resource(OvirtResource *resource, const char *href, const char *collection_name, GType resource_type, const char *resource_name) { const char *link = ovirt_resource_get_sub_collection(resource, href); if (link == NULL) return NULL; return ovirt_collection_new(link, collection_name, resource_type, resource_name); }
/** * ovirt_api_get_vm_pools: * @api: a #OvirtApi * * This method does not initiate any network activity, the collection * must be fetched with ovirt_collection_fetch() before having up-to-date * content. * * Return value: (transfer none): */ OvirtCollection *ovirt_api_get_vm_pools(OvirtApi *api) { const char *href; g_return_val_if_fail(OVIRT_IS_API(api), NULL); if (api->priv->vm_pools != NULL) return api->priv->vm_pools; href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(api), "vmpools"); if (href == NULL) return NULL; api->priv->vm_pools = ovirt_collection_new(href, "vmpools", OVIRT_TYPE_VM_POOL, "vmpool"); return api->priv->vm_pools; }
/** * ovirt_api_get_storage_domains: * @api: a #OvirtApi * * This method does not initiate any network activity, the collection * must be fetched with ovirt_collection_fetch() before having up-to-date * content. * * Return value: (transfer none): */ OvirtCollection *ovirt_api_get_storage_domains(OvirtApi *api) { const char *href; g_return_val_if_fail(OVIRT_IS_API(api), NULL); if (api->priv->storage_domains != NULL) return api->priv->storage_domains; href = ovirt_resource_get_sub_collection(OVIRT_RESOURCE(api), "storagedomains"); if (href == NULL) return NULL; api->priv->storage_domains = ovirt_collection_new(href, "storage_domains", OVIRT_TYPE_STORAGE_DOMAIN, "storage_domain"); return api->priv->storage_domains; }