示例#1
0
        /// <summary>
        /// Execute a command against the database. Returns the records affected or the list of records for queries. Command executed via POST.
        /// </summary>
        /// <param name="query">The query containing the command to execute</param>
        /// <param name="database">database name</param>
        /// <param name="language">The name of the language between those supported. OrientDB distribution comes with "sql" and GraphDB distribution has both "sql" and "gremlin"</param>
        /// <returns><see cref="OrientdbResponse{DynamicDictionary}"/></returns>
        /// <see cref="http://www.orientechnologies.com/docs/last/orientdb.wiki/OrientDB-REST.html#command"/>
        public OrientdbResponse <DynamicDictionary> Command(string query, string database, CommandLanguage language)
        {
            query.ThrowIfNullOrEmpty("query");
            database.ThrowIfNullOrEmpty("database");
            string url = "command/{0}/{1}".F(Encoded(database), Encoded(language.ToString().ToLower()));

            return(OrientdbResponse.Wrap(DoRequest <Dictionary <string, object> >("POST", url, query)));
        }
示例#2
0
        /// <summary>
        /// Disconnect from remote server
        /// </summary>
        /// <see cref="http://www.orientechnologies.com/docs/last/orientdb.wiki/OrientDB-REST.html#disconnect"/>
        public bool Disconnect()
        {
            const string url = "disconnect";
            OrientdbResponse <DynamicDictionary> request =
                OrientdbResponse.Wrap(DoRequest <Dictionary <string, object> >("GET", url));

            return(request.HttpStatusCode == 401);
        }
示例#3
0
        /// <summary>
        /// Connect to a remote server using basic authentication.
        /// </summary>
        /// <param name="name">database name</param>
        /// <see cref="http://www.orientechnologies.com/docs/last/orientdb.wiki/OrientDB-REST.html#connect"/>
        public bool Connect(string name)
        {
            name.ThrowIfNullOrEmpty("name");
            string url = "connect/{0}".F(Encoded(name));

            OrientdbResponse <DynamicDictionary> request =
                OrientdbResponse.Wrap(DoRequest <Dictionary <string, object> >("GET", url));

            return(request.HttpStatusCode == 204);
        }
示例#4
0
        /// <summary>
        /// Drop a database. Requires additional authentication to the server.
        /// </summary>
        /// <param name="name">database name</param>
        /// <remarks>
        /// Syntax: http://&lt;server&gt;:[&lt;port&gt;]/database/&lt;databaseName&gt;
        /// </remarks>
        public bool DeteteDatabase(string name)
        {
            name.ThrowIfNullOrEmpty("name");

            if (!DatabaseExist(name))
            {
                return(true);
            }

            string url = "database/{0}".F(Encoded(name));

            OrientdbResponse <DynamicDictionary> request =
                OrientdbResponse.Wrap(DoRequest <Dictionary <string, object> >("DELETE", url));

            return(request.HttpStatusCode == 204);
        }