Skip to content

Commit

Permalink
Merge pull request #11 from mbeacom/misc-updates
Browse files Browse the repository at this point in the history
Update docstrings, docs, and typing
  • Loading branch information
Mark Beacom authored Jun 28, 2019
2 parents 6112fb7 + c358087 commit 0721e4e
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 75 deletions.
Binary file removed .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions .stickler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
linters:
black:
fixer: false
flake8:
python: 3
max-line-length: 120
max-complexity: 20
fixer: false
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
password: $PYPI_PASSWORD
distributions: "sdist bdist_wheel"
skip_existing: true
skip_cleanup: true
on:
tags: true
- provider: releases
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Change Log

## [v0.0.3](https://github.com/mbeacom/cloudendure-python/tree/v0.0.3) (2019-06-20)
[Full Changelog](https://github.com/mbeacom/cloudendure-python/compare/v0.0.2...v0.0.3)

**Implemented enhancements:**

- Update pip dependencies [\#3](https://github.com/mbeacom/cloudendure-python/pull/3) ([mbeacom](https://github.com/mbeacom))

**Merged pull requests:**

- Update README.md [\#4](https://github.com/mbeacom/cloudendure-python/pull/4) ([twarnock2w](https://github.com/twarnock2w))

## [v0.0.2](https://github.com/mbeacom/cloudendure-python/tree/v0.0.2) (2019-06-16)
[Full Changelog](https://github.com/mbeacom/cloudendure-python/compare/v0.0.1...v0.0.2)

**Implemented enhancements:**

- Pointed API usecase and CLI additions [\#2](https://github.com/mbeacom/cloudendure-python/pull/2) ([mbeacom](https://github.com/mbeacom))

## [v0.0.1](https://github.com/mbeacom/cloudendure-python/tree/v0.0.1) (2019-05-30)


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
69 changes: 34 additions & 35 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# cloudendure-python

Python wrapper and CLI for CloudEndure
Python wrapper and CLI for [CloudEndure](https://www.cloudendure.com/)

[![Build Status](https://travis-ci.com/mbeacom/cloudendure-python.svg?branch=master)](https://travis-ci.com/mbeacom/cloudendure-python)

[Documentation](https://mbeacom.github.io/cloudendure-python/)

Package version: `0.0.3`
Package version: `0.0.4`

## Requirements

Expand Down Expand Up @@ -95,3 +95,7 @@ Logging in for the first time will generate the `~/.cloudendure.yml` file.
## Coming Soon

This project is currently a work in progress and will actively change. This client has not yet been finalized and is entirely subject to change.

## Changelog

Check out the [CHANGELOG](CHANGELOG.md)
13 changes: 6 additions & 7 deletions cloudendure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,12 @@ def login(self, username="", password=""):
_xsrf_token (str): The XSRF token to be used for subsequent API requests.
"""
endpoint: str = "login"
_username: str = self.config.active_config["username"] or username
_password: str = self.config.active_config["password"] or password
_auth: Dict[str, str] = {"username": _username, "password": _password}

# Attempt to login to the CloudEndure API via a POST request.
response: requests.Response = self.api_call(
"login", "post", data=json.dumps(_auth)
)
# response: requests.Response = self.session.post(f'{self.api_endpoint}/{endpoint}', json=_auth)
response: requests.Response = self.api_call("login", "post", data=json.dumps(_auth))

# Check whether or not the request was successful.
if response.status_code not in [200, 307]:
Expand All @@ -117,8 +113,11 @@ def login(self, username="", password=""):
)
raise CloudEndureUnauthorized()

# print('response: ', response, response.cookies)
_xsrf_token: str = str(response.cookies["XSRF-TOKEN"])
# Grab the XSRF token received from the response, as stored in cookies.
# _xsrf_token: str = str(response.cookies["XSRF-TOKEN"])
_xsrf_token: str = str(response.cookies.get("XSRF-TOKEN", ""))
if not _xsrf_token:
raise CloudEndureException("Failed to fetch a token from CloudEndure!")

# Strip the XSRF token of wrapping double-quotes from the cookie.
if _xsrf_token.startswith('"') and _xsrf_token.endswith('"'):
Expand Down
2 changes: 2 additions & 0 deletions cloudendure/cloudendure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
MIGRATION_WAVE: str = os.environ.get("CLOUDENDURE_MIGRATION_WAVE", "0")
CLONE_STATUS: str = os.environ.get("CLOUDENDURE_CLONE_STATUS", "NOT_STARTED")
MAX_LAG_TTL: int = int(os.environ.get("CLOUDENDURE_MAX_LAG_TTL", "90"))
SHARE_IMAGE: str = os.environ.get("", "")


class CloudEndure:
Expand Down Expand Up @@ -201,6 +202,7 @@ def update_blueprint(
except Exception as e:
print(f"Updating blueprint task failed! {e}")
return False
return True

def launch(self, project_id=global_project_id, launch_type="test", dry_run=False):
"""Launch the test target instances."""
Expand Down
20 changes: 20 additions & 0 deletions lambda/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
"""Define the Lambda specific exceptions."""


class LambdaException(Exception):
"""Define the generic AWS Lambda exception."""

pass


class InvalidPayload(LambdaException):
"""Define the exception to be raised when an invalid payload is encountered."""

pass


class ImproperlyConfigured(LambdaException):
"""Define the exception to be raised if the environment is improperly configured or missing."""

pass
Loading

0 comments on commit 0721e4e

Please sign in to comment.