import os
import sys

from pysuru import TsuruClient


TSURU_TARGET = os.environ.get('TSURU_TARGET', None)
TSURU_TOKEN = os.environ.get('TSURU_TOKEN', None)

if not TSURU_TARGET or not TSURU_TOKEN:
    print('You must set TSURU_TARGET and TSURU_TOKEN.')
    sys.exit(1)

api = TsuruClient(TSURU_TARGET, TSURU_TOKEN)

# List all apps that this token has access to
for app in api.apps:
    print(app.name)

# Update one specific app
api.apps.update('my-awesome-app', {'description': 'My awesome app'})

# Get information for one app
app = App.get('my-awesome-app')
print('%s: %s' % (app.name, app.description))

# List all services instances for app
for service in app.services:
    print('Service: %s' % service.name)

import os
import sys

from pysuru import TsuruClient


TSURU_TARGET = os.environ.get('TSURU_TARGET', None)
TSURU_TOKEN = os.environ.get('TSURU_TOKEN', None)

if not TSURU_TARGET or not TSURU_TOKEN:
    print('You must set TSURU_TARGET and TSURU_TOKEN env variables.')
    sys.exit(1)

# Creating TsuruClient instance
tsuru = TsuruClient(TSURU_TARGET, TSURU_TOKEN)

# List all apps that this user has access to
for app in tsuru.apps.list():
    print('App: {}'.format(app.name))

# Get information for one app
app = tsuru.apps.get('my-awesome-app')
print('{app.name}: {app.description}'.format(app=app))

# Update specific app
tsuru.apps.update('my-awesome-app', {'description': 'My new awesome description'})

Update examples to match docs
Update examples to match docs

Use the interface defined in the docs in the examples scripts.

  import os
  import sys
  
  from pysuru import TsuruClient
  
  
  TSURU_TARGET = os.environ.get('TSURU_TARGET', None)
  TSURU_TOKEN = os.environ.get('TSURU_TOKEN', None)
  
  if not TSURU_TARGET or not TSURU_TOKEN:
-     print('You must set TSURU_TARGET and TSURU_TOKEN.')
+     print('You must set TSURU_TARGET and TSURU_TOKEN env variables.')
      sys.exit(1)
  
+ # Creating TsuruClient instance
- api = TsuruClient(TSURU_TARGET, TSURU_TOKEN)
+ tsuru = TsuruClient(TSURU_TARGET, TSURU_TOKEN)
  
- # List all apps that this token has access to
+ # List all apps that this user has access to
+ for app in tsuru.apps.list():
+     print('App: {}'.format(app.name))
- for app in api.apps:
-     print(app.name)
- 
- # Update one specific app
- api.apps.update('my-awesome-app', {'description': 'My awesome app'})
  
  # Get information for one app
- app = App.get('my-awesome-app')
+ app = tsuru.apps.get('my-awesome-app')
- print('%s: %s' % (app.name, app.description))
+ print('{app.name}: {app.description}'.format(app=app))
  
+ # Update specific app
+ tsuru.apps.update('my-awesome-app', {'description': 'My new awesome description'})
- # List all services instances for app
- for service in app.services:
-     print('Service: %s' % service.name)
  
Update examples to match docs
## Code Before:
import os
import sys

from pysuru import TsuruClient


TSURU_TARGET = os.environ.get('TSURU_TARGET', None)
TSURU_TOKEN = os.environ.get('TSURU_TOKEN', None)

if not TSURU_TARGET or not TSURU_TOKEN:
    print('You must set TSURU_TARGET and TSURU_TOKEN.')
    sys.exit(1)

api = TsuruClient(TSURU_TARGET, TSURU_TOKEN)

# List all apps that this token has access to
for app in api.apps:
    print(app.name)

# Update one specific app
api.apps.update('my-awesome-app', {'description': 'My awesome app'})

# Get information for one app
app = App.get('my-awesome-app')
print('%s: %s' % (app.name, app.description))

# List all services instances for app
for service in app.services:
    print('Service: %s' % service.name)

## Instruction:
Update examples to match docs
## Code After:
import os
import sys

from pysuru import TsuruClient


TSURU_TARGET = os.environ.get('TSURU_TARGET', None)
TSURU_TOKEN = os.environ.get('TSURU_TOKEN', None)

if not TSURU_TARGET or not TSURU_TOKEN:
    print('You must set TSURU_TARGET and TSURU_TOKEN env variables.')
    sys.exit(1)

# Creating TsuruClient instance
tsuru = TsuruClient(TSURU_TARGET, TSURU_TOKEN)

# List all apps that this user has access to
for app in tsuru.apps.list():
    print('App: {}'.format(app.name))

# Get information for one app
app = tsuru.apps.get('my-awesome-app')
print('{app.name}: {app.description}'.format(app=app))

# Update specific app
tsuru.apps.update('my-awesome-app', {'description': 'My new awesome description'})
