1
0
Fork 0
arangodb/arangosh/ArangoShell/ArangoClient.h

556 lines
21 KiB
C++

////////////////////////////////////////////////////////////////////////////////
/// @brief arango shell client base
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_ARANGO_SHELL_ARANGO_CLIENT_H
#define TRIAGENS_ARANGO_SHELL_ARANGO_CLIENT_H 1
#include "Basics/Common.h"
#include "Rest/Endpoint.h"
// -----------------------------------------------------------------------------
// --SECTION-- forward declarations
// -----------------------------------------------------------------------------
namespace triagens {
namespace basics {
class ProgramOptionsDescription;
class ProgramOptions;
}
namespace rest {
class Endpoint;
}
// -----------------------------------------------------------------------------
// --SECTION-- class ArangoClient
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
namespace arango {
////////////////////////////////////////////////////////////////////////////////
/// @brief arango shell client base
////////////////////////////////////////////////////////////////////////////////
class ArangoClient {
private:
ArangoClient (const ArangoClient&);
ArangoClient operator= (const ArangoClient&);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public constants
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief default request timeout
////////////////////////////////////////////////////////////////////////////////
static double const DEFAULT_REQUEST_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @brief default number of retries
////////////////////////////////////////////////////////////////////////////////
static size_t const DEFAULT_RETRIES;
////////////////////////////////////////////////////////////////////////////////
/// @brief default connection timeout
////////////////////////////////////////////////////////////////////////////////
static double const DEFAULT_CONNECTION_TIMEOUT;
////////////////////////////////////////////////////////////////////////////////
/// @brief color red
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_RED;
////////////////////////////////////////////////////////////////////////////////
/// @brief color blod red
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BOLD_RED;
////////////////////////////////////////////////////////////////////////////////
/// @brief color green
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_GREEN;
////////////////////////////////////////////////////////////////////////////////
/// @brief color bold green
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BOLD_GREEN;
////////////////////////////////////////////////////////////////////////////////
/// @brief color blue
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BLUE;
////////////////////////////////////////////////////////////////////////////////
/// @brief color bold blue
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BOLD_BLUE;
////////////////////////////////////////////////////////////////////////////////
/// @brief color yellow
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_YELLOW;
////////////////////////////////////////////////////////////////////////////////
/// @brief color yellow
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BOLD_YELLOW;
////////////////////////////////////////////////////////////////////////////////
/// @brief color white
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_WHITE;
////////////////////////////////////////////////////////////////////////////////
/// @brief color bold white
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BOLD_WHITE;
////////////////////////////////////////////////////////////////////////////////
/// @brief color black
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BLACK;
////////////////////////////////////////////////////////////////////////////////
/// @brief color bold black
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BOLD_BLACK;
////////////////////////////////////////////////////////////////////////////////
/// @brief color blink
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BLINK;
////////////////////////////////////////////////////////////////////////////////
/// @brief color bright
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_BRIGHT;
////////////////////////////////////////////////////////////////////////////////
/// @brief color reset
////////////////////////////////////////////////////////////////////////////////
static char const * COLOR_RESET;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
ArangoClient ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the general and logging options
////////////////////////////////////////////////////////////////////////////////
void setupGeneral (triagens::basics::ProgramOptionsDescription& description);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the color options
////////////////////////////////////////////////////////////////////////////////
void setupColors (triagens::basics::ProgramOptionsDescription& description);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the auto-complete options
////////////////////////////////////////////////////////////////////////////////
void setupAutoComplete (triagens::basics::ProgramOptionsDescription& description);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the pretty-printing options
////////////////////////////////////////////////////////////////////////////////
void setupPrettyPrint (triagens::basics::ProgramOptionsDescription& description);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the pager options
////////////////////////////////////////////////////////////////////////////////
void setupPager (triagens::basics::ProgramOptionsDescription& description);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the server options
////////////////////////////////////////////////////////////////////////////////
void setupServer (triagens::basics::ProgramOptionsDescription& description);
////////////////////////////////////////////////////////////////////////////////
/// @brief parses command line and config file and prepares logging
////////////////////////////////////////////////////////////////////////////////
void parse (triagens::basics::ProgramOptions&,
triagens::basics::ProgramOptionsDescription& description,
int argc,
char* argv[],
string const& initFilename);
////////////////////////////////////////////////////////////////////////////////
/// @brief starts pager
////////////////////////////////////////////////////////////////////////////////
void startPager ();
////////////////////////////////////////////////////////////////////////////////
/// @brief stops pager
////////////////////////////////////////////////////////////////////////////////
void stopPager ();
////////////////////////////////////////////////////////////////////////////////
/// @brief print to pager
////////////////////////////////////////////////////////////////////////////////
void internalPrint (const char* format, const char* str = 0);
////////////////////////////////////////////////////////////////////////////////
/// @brief print info message
////////////////////////////////////////////////////////////////////////////////
void printWelcomeInfo ();
////////////////////////////////////////////////////////////////////////////////
/// @brief print bye-bye
////////////////////////////////////////////////////////////////////////////////
void printByeBye ();
////////////////////////////////////////////////////////////////////////////////
/// @brief creates an new endpoint
////////////////////////////////////////////////////////////////////////////////
void createEndpoint ();
////////////////////////////////////////////////////////////////////////////////
/// @brief creates an new endpoint
////////////////////////////////////////////////////////////////////////////////
void createEndpoint (string const& definition);
////////////////////////////////////////////////////////////////////////////////
/// @brief quiet start
////////////////////////////////////////////////////////////////////////////////
bool quiet () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief deactivate colors
////////////////////////////////////////////////////////////////////////////////
bool colors () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the auto completion flag
////////////////////////////////////////////////////////////////////////////////
bool autoComplete () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief use pretty print
////////////////////////////////////////////////////////////////////////////////
bool prettyPrint () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the output pager
////////////////////////////////////////////////////////////////////////////////
string const& outputPager () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief gets use pager
////////////////////////////////////////////////////////////////////////////////
bool usePager () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief sets use pager
////////////////////////////////////////////////////////////////////////////////
void setUsePager (bool);
////////////////////////////////////////////////////////////////////////////////
/// @brief gets endpoint to connect to as string
////////////////////////////////////////////////////////////////////////////////
string const& endpointString () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief sets endpoint to connect to as string
////////////////////////////////////////////////////////////////////////////////
void setEndpointString (string const&);
////////////////////////////////////////////////////////////////////////////////
/// @brief endpoint
////////////////////////////////////////////////////////////////////////////////
triagens::rest::Endpoint* endpointServer() const;
////////////////////////////////////////////////////////////////////////////////
/// @brief user to send to endpoint
////////////////////////////////////////////////////////////////////////////////
string const& username () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief password to send to endpoint
////////////////////////////////////////////////////////////////////////////////
string const& password () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief connect timeout (in seconds)
////////////////////////////////////////////////////////////////////////////////
double connectTimeout () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief request timeout (in seconds)
////////////////////////////////////////////////////////////////////////////////
double requestTimeout () const;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief configuration file
////////////////////////////////////////////////////////////////////////////////
string _configFile;
////////////////////////////////////////////////////////////////////////////////
/// @brief log level
////////////////////////////////////////////////////////////////////////////////
string _logLevel;
////////////////////////////////////////////////////////////////////////////////
/// @brief quiet start
////////////////////////////////////////////////////////////////////////////////
bool _quiet;
////////////////////////////////////////////////////////////////////////////////
/// @brief use color options
////////////////////////////////////////////////////////////////////////////////
bool _colorOptions;
////////////////////////////////////////////////////////////////////////////////
/// @brief deactivate colors
////////////////////////////////////////////////////////////////////////////////
bool _noColors;
////////////////////////////////////////////////////////////////////////////////
/// @brief use auto-complete options
////////////////////////////////////////////////////////////////////////////////
bool _autoCompleteOptions;
////////////////////////////////////////////////////////////////////////////////
/// @brief disable auto completion
////////////////////////////////////////////////////////////////////////////////
bool _noAutoComplete;
////////////////////////////////////////////////////////////////////////////////
/// @brief use pretty-print options
////////////////////////////////////////////////////////////////////////////////
bool _prettyPrintOptions;
////////////////////////////////////////////////////////////////////////////////
/// @brief use pretty print
////////////////////////////////////////////////////////////////////////////////
bool _prettyPrint;
////////////////////////////////////////////////////////////////////////////////
/// @brief use pager options
////////////////////////////////////////////////////////////////////////////////
bool _pagerOptions;
////////////////////////////////////////////////////////////////////////////////
/// @brief the output pager
////////////////////////////////////////////////////////////////////////////////
string _outputPager;
////////////////////////////////////////////////////////////////////////////////
/// @brief the pager FILE
////////////////////////////////////////////////////////////////////////////////
FILE* _pager;
////////////////////////////////////////////////////////////////////////////////
/// @brief use pager
////////////////////////////////////////////////////////////////////////////////
bool _usePager;
////////////////////////////////////////////////////////////////////////////////
/// @brief use server options
////////////////////////////////////////////////////////////////////////////////
bool _serverOptions;
////////////////////////////////////////////////////////////////////////////////
/// @brief endpoint to connect to as string
////////////////////////////////////////////////////////////////////////////////
string _endpointString;
////////////////////////////////////////////////////////////////////////////////
/// @brief endpoint
////////////////////////////////////////////////////////////////////////////////
triagens::rest::Endpoint* _endpointServer;
////////////////////////////////////////////////////////////////////////////////
/// @brief user to send to endpoint
////////////////////////////////////////////////////////////////////////////////
string _username;
////////////////////////////////////////////////////////////////////////////////
/// @brief password to send to endpoint
////////////////////////////////////////////////////////////////////////////////
string _password;
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not a password was specified on the command line
////////////////////////////////////////////////////////////////////////////////
bool _hasPassword;
////////////////////////////////////////////////////////////////////////////////
/// @brief connect timeout (in seconds)
////////////////////////////////////////////////////////////////////////////////
double _connectTimeout;
////////////////////////////////////////////////////////////////////////////////
/// @brief request timeout (in seconds)
////////////////////////////////////////////////////////////////////////////////
double _requestTimeout;
};
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
// End: