Code Monkey home page Code Monkey logo

aiogcd's People

Contributors

egalpin avatar joente avatar jomido avatar koos85 avatar robbm1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aiogcd's Issues

Add bytes value to ORM

Add type bytesValue to the ORM layer as it is possible to insert bytes values.

Within GCD a bytesValue will be stored as a blobValue.

Add limit and offset support to `get_entities_by_kind`

When no GcdModel is used, the function get_entities_by_kind should support an offset, limit and thus cursor to query entities in batches.

Since this requires a cursor, the result of the function should depend on the limit argument. When None, the "old" behavior should be honored for backwards compatibility. When a limit is set, the function should return a (list, cursor) tuple.

Infinite loop while obtaining ServiceAccount token

service_account_token.py

    async with ensure_session(self.session) as s:
        response = await s.post(
            url,
            data=payload,
            headers=headers,
            timeout=60
        )

    return await response.json()

causes infinite loop in some requests, changing to:

     async with ensure_session(self.session) as s:
        response = await s.post(
            url,
            data=payload,
            headers=headers,
            timeout=60
        )

	json = await response.json()
		
    return json

helps

Unable to unpack blobValues which contain bytes

The fix to download blobValues (bytes) is not totally correct, see error below:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "some.py", line 123, in func
    values, cursor = await _gcd.get_entities_by_kind(
  File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/connector.py", line 333, in get_entities_by_kind
    return await self._get_entities_cursor(data)
  File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/connector.py", line 280, in _get_entities_cursor
    return [Entity(result['entity']) for result in results], cursor
  File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/connector.py", line 280, in <listcomp>
    return [Entity(result['entity']) for result in results], cursor
  File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/entity.py", line 44, in __init__
    setattr(self, prop, value_from_dict(val))
  File "/usr/local/lib/python3.8/site-packages/aiogcd/connector/utils.py", line 81, in value_from_dict
    (val + pad).replace(b'-', b'+').replace(b'_', b'/'))
TypeError: can only concatenate str (not "bytes") to str

get_entity_by_key should be implemented as a lookup, not a query

One important feature of obtaining an entity by its key is that the read_consistency is strong. In the case of a global query, read_consistency is eventual and could result in undesired consequences depending on ones expectation of the library function's behaviour. Based on the REST API, implementing lookup would provide both get_entity_by_key and get_entities_by_keys for free (having one implies having the other). Luckily, json.dumps(<key>.get_dict()) should provide the right shape of data required for the lookup REST API :-)

I think it would be good to emulate the behaviour of this function in the official python module code (synchronous).

I would be happy to open a PR for this, but am not sure when I'll have time to do so. Logging this here in case someone wants to take a crack at it before I have the chance!

For reference/reading:
aiogcd lookup implementation
GCloud API Doc - lookup

Alternative authentication methods

Thanks for this project, excited to have found it!

Is there a way to use service accounts (with JSON key) to authorize requests with this lib? Happy to work on adding this functionality if there is a known path!

Kind is not set correctly for a model

When omitting the __kind__ property in a model class, the kind for the model is not set correctly.

We expect the following model:

class User(GcdModel):
    ...

... to have kind User, just like this model:

class TestUser(GcdModel):
    __kind__ = 'User'

But instead the first class sets kind None.

Filter in combination with an ArrayValue type seems to fail

When using a filter with an ArrayValue it seems to fail:

TypeError: Expecting a value of type 'int'...

The ArrayType requires a special way of filtering, for example:

Suppose there exists an entity with an arr property with the array

[123, 456, 789]

The following should return that entity:

Entity.filter(Entity.arr == 456)

Issue running Alice example

When executing the insert_alice example, I receive the following error:

IndexError: Both "id" and "name" are missing in pair: {'kind': 'User'}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.