Example #1
0
 def create_amphora(self, name: str, description: str, **kwargs) -> Amphora:
     """
     Creates a new Amphora
     params:
         name: str                       the name of the Amphora
         description :str                a description of the Amphora
         **kwargs:
             price: float                    a monthly fee (in AUD)
             lat: float                      latitude
             lon: float                      longitude
             terms_of_use_id: str            id reference of the terms of use to apply
             labels: [str]                   a list (max 5) of labels
     returns:
         amphora.Amphora
     """
     price = kwargs["price"] if "price" in kwargs else 0
     lat: float = kwargs["lat"] if "lat" in kwargs else None
     lon: float = kwargs["lon"] if "lon" in kwargs else None
     terms_of_use_id: str = kwargs[
         "terms_of_use_id"] if "terms_of_use_id" in kwargs else None
     labels: [str] = kwargs["labels"] if "labels" in kwargs else []
     model = api.CreateAmphora(name=name,
                               description=description,
                               price=price,
                               terms_of_use_id=terms_of_use_id,
                               labels=",".join(labels),
                               lat=lat,
                               lon=lon)
     details = api.AmphoraeApi(self.apiClient).amphorae_create(model)
     return Amphora(self.apiClient, details.id)
Example #2
0
    def update(self, **kwargs):
        """
        Updates this Amphora
        params:
            id: str                         the id of the Amphora
            **kwargs:
                name: str                       the name of the Amphora
                description :str                a description of the Amphora
                price: float                    a monthly fee (in AUD)
                lat: float                      latitude
                lon: float                      longitude
                terms_of_use_id: str            id reference of the terms of use to apply
                labels: [str]                   a list (max 5) of labels
        returns:
            amphora.Amphora
        """
        amphoraApi = api.AmphoraeApi(self._apiClient)
        model = amphoraApi.amphorae_read(self.amphora_id)
        model.name = kwargs["name"] if "name" in kwargs else model.name
        model.description = kwargs[
            "description"] if "description" in kwargs else model.description
        model.price = kwargs["price"] if "price" in kwargs else model.price
        model.lat: float = kwargs["lat"] if "lat" in kwargs else model.lat
        model.lon: float = kwargs["lon"] if "lon" in kwargs else model.lon
        model.terms_of_use_id: str = kwargs[
            "terms_of_use_id"] if "terms_of_use_id" in kwargs else model.terms_of_use_id
        model.labels: [
            str
        ] = ",".join(kwargs["labels"]) if "labels" in kwargs else model.labels

        model = amphoraApi.amphorae_update(self.amphora_id, model)
Example #3
0
    def buy_amphora(self, amphora_id):
        """
        Buys an amphora with your credentials
        Amphora id needs to be supplied
        """

        purchaseAPI = api.AmphoraeApi(self.apiClient)
        sep = " "
        print(sep.join(['Trying to buy Amphora with id', amphora_id]))
        try:
            buyAmphora = purchaseAPI.purchases_purchase(amphora_id)
        except:
            buyAmphora = "Something went wrong, Amphora couldn't be purchased"
        return buyAmphora
Example #4
0
    def list_amphora(self, scope, access_type, take=64, skip=0):
        """
        :param async_req bool: execute request asynchronously 
        :param str scope: 'self' or 'organisation'. Defaults to self. 
        :param str access_type: 'created' or 'purchased'. Defaults to created. 
        :param int take: Gets or sets how many items to return. Defaults to 64. 
        :param int skip: Gets or sets how many items to skip before returning. Defaults to 0.
        returns [DetailedAmphora]
        """

        amphoraApi = api.AmphoraeApi(self.apiClient)
        return amphoraApi.amphorae_list(scope=scope,
                                        access_type=access_type,
                                        skip=skip,
                                        take=take)
Example #5
0
 def amphoraeApi(self) -> api.AmphoraeApi:
     return api.AmphoraeApi(self.apiClient)
import amphora_api_client as a10a
from amphora_api_client.rest import ApiException
from amphora_api_client.configuration import Configuration

# Import non-Amphora librarys
from array import array
import os
import numpy as np
import time
from datetime import datetime, timedelta

# Login to amphoradata.com
credentials = Credentials(username=os.getenv('username'),
                          password=os.getenv('password'))
client = AmphoraDataRepositoryClient(credentials)
amphora_api = a10a.AmphoraeApi(client.apiClient)


# Define model function
def time_product(date_time):
    time_hour = date_time.hour
    time_minute = date_time.minute
    time_second = date_time.second

    time_prod = time_hour * time_minute * time_second

    return time_prod


#####################################