# Path: flask_github/client/messages.py
# class Key(msgs.Message):
#   id = msgs.IntegerField(1, default=0)
#   key = msgs.StringField(2)
#   title = msgs.StringField(3)
# 
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
#   response = msgs.MessageField('Key', 1)
# 
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
#   response = msgs.MessageField('Key', 1, repeated=True)


from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse

from __future__ import unicode_literals

class ReposKeys:
  def __init__(self, client):
    self.client = client

  def list(self, repo, user=None):
    return self.client.get(
      'repos/%s/%s/keys' % (
        self.client.user(user), repo), msg_type=KeyListResponse)

  def get(self, repo, id, user=None):
    return self.client.get(
      'repos/%s/%s/keys/%s' % (
        self.client.user(user), repo, id), msg_type=KeyResponse)

  def create(self, repo, title, key, user=None):
    msg = Key(
      title=title,
      key=key)
    return self._create(repo=repo, msg=msg, user=user)

  def _create(self, repo, msg, user=None):
    return self.client.post(
      'repos/%s/%s/keys' % (
        self.client.user(user), repo), data=msg, msg_type=KeyResponse)

  def edit(self, repo, id, title=None, key=None, user=None):

# Path: flask_github/client/messages.py
# class Key(msgs.Message):
#   id = msgs.IntegerField(1, default=0)
#   key = msgs.StringField(2)
#   title = msgs.StringField(3)
# 
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
#   response = msgs.MessageField('Key', 1)
# 
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
#   response = msgs.MessageField('Key', 1, repeated=True)


# Path: flask_github/client/repos/reposkeys.py
from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse

from __future__ import unicode_literals

class ReposKeys:
  def __init__(self, client):
    self.client = client

  def list(self, repo, user=None):
    return self.client.get(
      'repos/%s/%s/keys' % (
        self.client.user(user), repo), msg_type=KeyListResponse)

  def get(self, repo, id, user=None):
    return self.client.get(
      'repos/%s/%s/keys/%s' % (
        self.client.user(user), repo, id), msg_type=KeyResponse)

  def create(self, repo, title, key, user=None):
    msg = Key(
      title=title,
      key=key)
    return self._create(repo=repo, msg=msg, user=user)

  def _create(self, repo, msg, user=None):
    return self.client.post(
      'repos/%s/%s/keys' % (
        self.client.user(user), repo), data=msg, msg_type=KeyResponse)

  def edit(self, repo, id, title=None, key=None, user=None):

    msg = Key(
