def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=FollowerRelationship,
             version="v1",
         ),
         follower_relationship_id=obj.id,
     )
     links["user"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.user_id,
     )
     links["follower"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.follower_id,
     )
     return links.to_dict()
예제 #2
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(subject=Person),
         person_id=obj.id,
     )
     return links.to_dict()
예제 #3
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(subject=Address),
         address_id=obj.id,
     )
     return links.to_dict()
예제 #4
0
    def get_links(self, obj):
        links = Links()
        links["self"] = Link.for_(
            Operation.Retrieve,
            Namespace(subject=OrderEvent, version="v1",),
            order_event_id=obj.id,
        )

        return links.to_dict()
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=Example,
             version="v1",
         ),
         example_id=obj.id,
     )
     return links.to_dict()
예제 #6
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(subject=Topping, version="v1",),
         topping_id=obj.id,
     )
     links["parent:pizza"] = Link.for_(
         Operation.Search, Namespace(subject=Pizza, version="v1"), id=obj.pizza_id
     )
     return links.to_dict()
예제 #7
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         ns=Namespace(
             subject=Address,
             path=Namespace(subject=Person, ).instance_path,
         ),
         person_id=obj.person_id,
         address_id=obj.id,
     )
     return links.to_dict()
예제 #8
0
def test_links_init_list():
    links = Links(foo=[
        Link("bar"),
        Link("baz"),
    ])
    assert_that(
        links.to_dict(),
        is_(equal_to({
            "foo": [{
                "href": "bar",
            }, {
                "href": "baz",
            }],
        })))
예제 #9
0
def test_links_as_item():
    links = Links()
    links["foo"] = Link("foo")
    links["bar"] = Link("bar")

    assert_that(
        links.to_dict(),
        is_(equal_to({
            "foo": {
                "href": "foo",
            },
            "bar": {
                "href": "bar",
            },
        })))
예제 #10
0
def test_links_init():
    links = Links(
        foo=Link("foo"),
        bar=Link("bar"),
    )
    assert_that(
        links.to_dict(),
        is_(equal_to({
            "foo": {
                "href": "foo",
            },
            "bar": {
                "href": "bar",
            },
        })))
예제 #11
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.id,
     )
     links["tweets"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="tweets",
             version="v1",
         ),
         user_id=obj.id,
     )
     links["followers"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="followers",
             version="v1",
         ),
         user_id=obj.id,
     )
     links["following"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="following",
             version="v1",
         ),
         user_id=obj.id,
     )
     links["feed"] = Link.for_(
         Operation.SearchFor,
         Namespace(
             subject=User,
             object_="feed",
             version="v1",
         ),
         user_id=obj.id,
     )
     return links.to_dict()
예제 #12
0
 def links(self):
     links = Links()
     links["self"] = Link.for_(self.operation, self.ns, qs=self.page.to_tuples(), **self.extra)
     if self.page.offset + self.page.limit < self.count:
         links["next"] = Link.for_(self.operation, self.ns, qs=self.page.next().to_tuples(), **self.extra)
     if self.page.offset > 0:
         links["prev"] = Link.for_(self.operation, self.ns, qs=self.page.prev().to_tuples(), **self.extra)
     return links
예제 #13
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=Order,
             version="v1",
         ),
         order_id=obj.id,
     )
     # links["child:pizza"] = Link.for_(
     #     Operation.Retrieve,
     #     Namespace(
     #         subject=Pizza,
     #         version="v1",
     #     ),
     #     pizza_id=obj.pizza_id,
     # )
     return links.to_dict()
예제 #14
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=Tweet,
             version="v1",
         ),
         tweet_id=obj.id,
     )
     links["user"] = Link.for_(
         Operation.Retrieve,
         Namespace(
             subject=User,
             version="v1",
         ),
         user_id=obj.user_id,
     )
     return links.to_dict()
예제 #15
0
    def links(self):
        """
        Include a self link.

        """
        links = Links()
        links["self"] = Link.for_(self._operation,
                                  self._ns,
                                  qs=self._page.to_items(),
                                  **self._context)
        return links
예제 #16
0
        def discover():
            # accept pagination limit from request
            page = Page.from_query_string(load_query_string_data(page_schema))
            page.offset = 0

            response_data = dict(_links=Links({
                "self":
                Link.for_(Operation.Discover, ns, qs=page.to_tuples()),
                "search": [
                    link for link in iter_links(
                        self.find_matching_endpoints(ns), page)
                ],
            }).to_dict())
            return make_response(response_data)
예제 #17
0
def test_links_empty():
    links = Links()
    assert_that(links.to_dict(), is_(equal_to({})))
예제 #18
0
 def get_links(self, obj):
     links = Links()
     links["self"] = Link.for_(Operation.Retrieve, Person, person_id=obj.id)
     return links.to_dict()