rawsc.service.RawsService Class Reference

Inherits AtomService.

Inherited by rawsc.rams.service.RamsService, rawsc.rase.service.RaseService, rawsc.rass.service.RassService, and rawsc.rats.service.RatsService.

List of all members.


Detailed Description

Contains elements needed for Raws login and CRUD request headers.

Maintains additional headers (tokens for example) needed for the Raws services to allow a user to perform inserts, updates, and deletes.

Public Member Functions

def __init__
def set_credentials
def Get
def GetMedia
def GetEntry
def GetFeed
def GetNext
def Post
def PostOrPut
def Put
def Delete


Member Function Documentation

def rawsc.service.RawsService.__init__ (   self,
  username = None,
  password = None,
  source = None,
  server = None,
  port = None,
  additional_headers = None,
  handler = None,
  ssl = False 
)

Creates an object of type RawsService.

Args: username: string (optional) The username for authentication. password: string (optional) The user's password. source: string (optional) The name of the user's application. server: string (optional) The name of the server to which a connection will be opened. (eg 'rass.cdn01.rambla.be'). additional_headers: dictionary (optional) Any additional headers which should be included with CRUD operations. handler: module (optional) The module whose HttpRequest function should be used when making requests to the server. The default value is atom.service. ssl: bool (optional) Use SSL encryption.

Reimplemented in rawsc.rase.service.RaseService, rawsc.rass.service.RassService, rawsc.rats.service.RatsService, and rawsc.rams.service.RamsService.

def rawsc.service.RawsService.set_credentials (   self,
  username,
  password,
  server = None,
  port = None 
)

Sets the authentication credentials and server name on the object.

def rawsc.service.RawsService.Get (   self,
  uri,
  extra_headers = None,
  redirects_remaining = 4,
  encoding = 'UTF-8',
  converter = None 
)

Query the Raws API with the given URI

The uri is the portion of the URI after the server value

To perform a query against RAMS, set the server to 'rams.mon01.rambla.be' and set the uri to '/traffic/...', where ... is your query. For example, to get recursive file traffic: '/traffic/?kind=recursive'

Args: uri: string The query in the form of a URI. Example: '/traffic/?kind=recursive'. extra_headers: dictionary (optional) Extra HTTP headers to be included in the GET request. These headers are in addition to those stored in the client's additional_headers property. The client automatically sets the Content-Type and Authorization headers. redirects_remaining: int (optional) Tracks the number of additional redirects this method will allow. If the service object receives a redirect and remaining is 0, it will not follow the redirect. This was added to avoid infinite redirect loops. encoding: string (optional) The character encoding for the server's response. Default is UTF-8 converter: func (optional) A function which will transform the server's results before it is returned. Example: use RawsFeedFromString to parse the server response as if it were a RawsFeed.

Returns: If there is no ResultsTransformer specified in the call, a RawsFeed or RawsEntry depending on which is sent from the server. If the response is niether a feed or entry and there is no ResultsTransformer, return a string. If there is a ResultsTransformer, the returned value will be that of the ResultsTransformer function.

def rawsc.service.RawsService.GetMedia (   self,
  uri,
  extra_headers = None,
  file_path = None 
)

Returns a MediaSource containing media and its metadata from the given URI string, storing it into the local file_path.

def rawsc.service.RawsService.GetEntry (   self,
  uri,
  extra_headers = None 
)

Query the Raws API with the given URI and receive an Entry.

See also documentation for rawsc.service.Get

Args: uri: string The query in the form of a URI. Example: '/item/mysubdir/myfile.mp4'. extra_headers: dictionary (optional) Extra HTTP headers to be included in the GET request. These headers are in addition to those stored in the client's additional_headers property. The client automatically sets the Content-Type and Authorization headers.

Returns: A RawsEntry built from the XML in the server's response.

def rawsc.service.RawsService.GetFeed (   self,
  uri,
  extra_headers = None,
  converter = rawsc.RawsFeedFromString 
)

Query the Raws API with the given URI and receive a Feed.

See also documentation for rawsc.service.Get

Args: uri: string The query in the form of a URI. Example: '/dir/mysubdir/?kind=file'. extra_headers: dictionary (optional) Extra HTTP headers to be included in the GET request. These headers are in addition to those stored in the client's additional_headers property. The client automatically sets the Content-Type and Authorization headers.

Returns: A RawsFeed built from the XML in the server's response.

def rawsc.service.RawsService.GetNext (   self,
  feed 
)

Requests the next 'page' of results in the feed.

This method uses the feed's next link to request an additional feed and uses the class of the feed to convert the results of the GET request.

Args: feed: atom.Feed or a subclass. The feed should contain a next link and the type of the feed will be applied to the results from the server. The new feed which is returned will be of the same class as this feed which was passed in.

Returns: A new feed representing the next set of results in the server's feed. The type of this feed will match that of the feed argument.

def rawsc.service.RawsService.Post (   self,
  data,
  uri,
  extra_headers = None,
  url_params = None,
  escape_params = True,
  redirects_remaining = 4,
  media_source = None,
  converter = None 
)

Insert or update data into a Raws service at the given URI.

Args: data: string, ElementTree._Element, atom.Entry, or rawsc.RawsEntry The XML to be sent to the uri. uri: string The location (feed) to which the data should be inserted. Example: '/job/'. extra_headers: dict (optional) HTTP headers which are to be included. The client automatically sets the Content-Type, Authorization, and Content-Length headers. url_params: dict (optional) Additional URL parameters to be included in the URI. These are translated into query arguments in the form '&dict_key=value&...'. Example: {'paginate_by': '50'} becomes &paginate_by=50 escape_params: boolean (optional) If false, the calling code has already ensured that the query will form a valid URL (all reserved characters have been escaped). If true, this method will escape the query and any URL parameters provided. media_source: MediaSource (optional) Container for the media to be sent along with the entry, if provided. converter: func (optional) A function which will be executed on the server's response. Often this is a function like RawsEntryFromString which will parse the body of the server's response and return a RawsEntry.

Returns: If the post succeeded, this method will return a RawsFeed, RawsEntry, or the results of running converter on the server's result body (if converter was specified).

def rawsc.service.RawsService.PostOrPut (   self,
  verb,
  data,
  uri,
  extra_headers = None,
  url_params = None,
  escape_params = True,
  redirects_remaining = 4,
  media_source = None,
  converter = None 
)

Insert data into a Raws service at the given URI.

Args: verb: string, either 'POST' or 'PUT' data: string, ElementTree._Element, atom.Entry, or rawsc.RawsEntry The XML to be sent to the uri. uri: string The location (feed) to which the data should be inserted. Example: '/job/'. extra_headers: dict (optional) HTTP headers which are to be included. The client automatically sets the Content-Type, Authorization, and Content-Length headers. url_params: dict (optional) Additional URL parameters to be included in the URI. These are translated into query arguments in the form '&paginate_by=50&...'. Example: {'paginate_by': '50'} becomes &paginate_by=50 escape_params: boolean (optional) If false, the calling code has already ensured that the query will form a valid URL (all reserved characters have been escaped). If true, this method will escape the query and any URL parameters provided. media_source: MediaSource (optional) Container for the media to be sent along with the entry, if provided. converter: func (optional) A function which will be executed on the server's response. Often this is a function like RawsEntryFromString which will parse the body of the server's response and return a RawsEntry.

Returns: If the post succeeded, this method will return a RawsFeed, RawsEntry, or the results of running converter on the server's result body (if converter was specified).

def rawsc.service.RawsService.Put (   self,
  data,
  uri,
  extra_headers = None,
  url_params = None,
  escape_params = True,
  redirects_remaining = 3,
  media_source = None,
  converter = None 
)

Updates an entry at the given URI.

Args: data: string, ElementTree._Element, or xml_wrapper.ElementWrapper The XML containing the updated data. uri: string A URI indicating entry to which the update will be applied. Example: '/dir/my_new_subdir/' extra_headers: dict (optional) HTTP headers which are to be included. The client automatically sets the Content-Type, Authorization, and Content-Length headers. url_params: dict (optional) Additional URL parameters to be included in the URI. These are translated into query arguments in the form '&paginate_by=50&...'. Example: {'paginate_by': '50'} becomes &paginate_by=50 escape_params: boolean (optional) If false, the calling code has already ensured that the query will form a valid URL (all reserved characters have been escaped). If true, this method will escape the query and any URL parameters provided. converter: func (optional) A function which will be executed on the server's response. Often this is a function like RawsEntryFromString which will parse the body of the server's response and return a RawsEntry.

Returns: If the put succeeded, this method will return a RawsFeed, RawsEntry, or the results of running converter on the server's result body (if converter was specified).

def rawsc.service.RawsService.Delete (   self,
  uri,
  extra_headers = None,
  url_params = None,
  escape_params = True,
  redirects_remaining = 4 
)

Deletes the entry at the given URI.

Args: uri: string The URI of the entry to be deleted. Example: '/item/mysubdir/myfile.mp4' extra_headers: dict (optional) HTTP headers which are to be included. The client automatically sets the Content-Type and Authorization headers. url_params: dict (optional) Additional URL parameters to be included in the URI. These are translated into query arguments in the form '&paginate_by=50&...'. Example: {'paginate_by': '50'} becomes &paginate_by=50 escape_params: boolean (optional) If false, the calling code has already ensured that the query will form a valid URL (all reserved characters have been escaped). If true, this method will escape the query and any URL parameters provided.

Returns: True if the entry was deleted.


Generated on Mon Mar 28 15:03:40 2011 for rawsc by  doxygen 1.5.3