import asyncio
import uuid
import json

import requests
from requests.exceptions import HTTPError

from pyeventstore.events import (get_all_events,
                                 start_subscription,
                                 publish_events)
from pyeventstore.stream_page import StreamPage


class Client:

    def __init__(self, host, secure=False, port=2113):
        proto = "https" if secure else "http"
        self.uri_base = '{}://{}:{}'.format(proto, host, port)

    @asyncio.coroutine
    def publish_events(self, stream_name, events):
        uri = self.stream_head_uri(stream_name)
        yield from publish_events(uri, events)

    def stream_head_uri(self, stream_name):
        return '{}/streams/{}'.format(self.uri_base, stream_name)

    @asyncio.coroutine
    def get_all_events(self, stream_name):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from get_all_events(head_uri))

    @asyncio.coroutine
    def subscribe(self, stream_name, interval_seconds=1):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from start_subscription(head_uri, interval_seconds))

    def get_projection(self, projection_name):
        uri = self.uri_base + '/projection/{}'.format(projection_name)
        headers = {'Accept': 'application/json'}
        response = requests.get(uri, headers=headers)
        return response.json()

    def get_projection_state(self, projection_name, partition=None):
        uri = self.uri_base + '/projection/{}/state'.format(projection_name)
        headers = {'Accept': 'application/json'}
        params = {}
        if partition:
            params['partition'] = partition
        response = requests.get(uri, headers=headers, params=params)
        return response.json()

import asyncio
import uuid
import json

from pyeventstore.events import (get_all_events,
                                 start_subscription,
                                 publish_events)

class Client:

    def __init__(self, host, secure=False, port=2113):
        proto = "https" if secure else "http"
        self.uri_base = '{}://{}:{}'.format(proto, host, port)

    @asyncio.coroutine
    def publish_events(self, stream_name, events):
        uri = self.stream_head_uri(stream_name)
        yield from publish_events(uri, events)

    def stream_head_uri(self, stream_name):
        return '{}/streams/{}'.format(self.uri_base, stream_name)

    @asyncio.coroutine
    def get_all_events(self, stream_name):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from get_all_events(head_uri))

    @asyncio.coroutine
    def subscribe(self, stream_name, interval_seconds=1):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from start_subscription(head_uri, interval_seconds))

Remove projections methods for now
Remove projections methods for now

  import asyncio
  import uuid
  import json
  
- import requests
- from requests.exceptions import HTTPError
- 
  from pyeventstore.events import (get_all_events,
                                   start_subscription,
                                   publish_events)
- from pyeventstore.stream_page import StreamPage
- 
  
  class Client:
  
      def __init__(self, host, secure=False, port=2113):
          proto = "https" if secure else "http"
          self.uri_base = '{}://{}:{}'.format(proto, host, port)
  
      @asyncio.coroutine
      def publish_events(self, stream_name, events):
          uri = self.stream_head_uri(stream_name)
          yield from publish_events(uri, events)
  
      def stream_head_uri(self, stream_name):
          return '{}/streams/{}'.format(self.uri_base, stream_name)
  
      @asyncio.coroutine
      def get_all_events(self, stream_name):
          head_uri = self.stream_head_uri(stream_name)
          return (yield from get_all_events(head_uri))
  
      @asyncio.coroutine
      def subscribe(self, stream_name, interval_seconds=1):
          head_uri = self.stream_head_uri(stream_name)
          return (yield from start_subscription(head_uri, interval_seconds))
  
-     def get_projection(self, projection_name):
-         uri = self.uri_base + '/projection/{}'.format(projection_name)
-         headers = {'Accept': 'application/json'}
-         response = requests.get(uri, headers=headers)
-         return response.json()
- 
-     def get_projection_state(self, projection_name, partition=None):
-         uri = self.uri_base + '/projection/{}/state'.format(projection_name)
-         headers = {'Accept': 'application/json'}
-         params = {}
-         if partition:
-             params['partition'] = partition
-         response = requests.get(uri, headers=headers, params=params)
-         return response.json()
- 
Remove projections methods for now
## Code Before:
import asyncio
import uuid
import json

import requests
from requests.exceptions import HTTPError

from pyeventstore.events import (get_all_events,
                                 start_subscription,
                                 publish_events)
from pyeventstore.stream_page import StreamPage


class Client:

    def __init__(self, host, secure=False, port=2113):
        proto = "https" if secure else "http"
        self.uri_base = '{}://{}:{}'.format(proto, host, port)

    @asyncio.coroutine
    def publish_events(self, stream_name, events):
        uri = self.stream_head_uri(stream_name)
        yield from publish_events(uri, events)

    def stream_head_uri(self, stream_name):
        return '{}/streams/{}'.format(self.uri_base, stream_name)

    @asyncio.coroutine
    def get_all_events(self, stream_name):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from get_all_events(head_uri))

    @asyncio.coroutine
    def subscribe(self, stream_name, interval_seconds=1):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from start_subscription(head_uri, interval_seconds))

    def get_projection(self, projection_name):
        uri = self.uri_base + '/projection/{}'.format(projection_name)
        headers = {'Accept': 'application/json'}
        response = requests.get(uri, headers=headers)
        return response.json()

    def get_projection_state(self, projection_name, partition=None):
        uri = self.uri_base + '/projection/{}/state'.format(projection_name)
        headers = {'Accept': 'application/json'}
        params = {}
        if partition:
            params['partition'] = partition
        response = requests.get(uri, headers=headers, params=params)
        return response.json()

## Instruction:
Remove projections methods for now
## Code After:
import asyncio
import uuid
import json

from pyeventstore.events import (get_all_events,
                                 start_subscription,
                                 publish_events)

class Client:

    def __init__(self, host, secure=False, port=2113):
        proto = "https" if secure else "http"
        self.uri_base = '{}://{}:{}'.format(proto, host, port)

    @asyncio.coroutine
    def publish_events(self, stream_name, events):
        uri = self.stream_head_uri(stream_name)
        yield from publish_events(uri, events)

    def stream_head_uri(self, stream_name):
        return '{}/streams/{}'.format(self.uri_base, stream_name)

    @asyncio.coroutine
    def get_all_events(self, stream_name):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from get_all_events(head_uri))

    @asyncio.coroutine
    def subscribe(self, stream_name, interval_seconds=1):
        head_uri = self.stream_head_uri(stream_name)
        return (yield from start_subscription(head_uri, interval_seconds))
