-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from ultradns/hatch_deployment
Hatch deployment
- Loading branch information
Showing
8 changed files
with
211 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Code_Analysis_Workflow | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
Code_Analysis_Job: | ||
runs-on: ubuntu-latest | ||
environment: test | ||
steps: | ||
- | ||
name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- | ||
name: Setup Python environment | ||
uses: actions/setup-python@v4 | ||
- | ||
name: Install Dependencies | ||
run: pip install requests | ||
- | ||
name: Running acceptace test | ||
run: python test.py | ||
env: | ||
ULTRADNS_UNIT_TEST_USERNAME: ${{ secrets.ULTRADNS_UNIT_TEST_USERNAME }} | ||
ULTRADNS_UNIT_TEST_PASSWORD: ${{ secrets.ULTRADNS_UNIT_TEST_PASSWORD }} | ||
ULTRADNS_UNIT_TEST_HOST_URL: ${{ secrets.ULTRADNS_UNIT_TEST_HOST_URL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Release_Workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
Code_Analysis_Job: | ||
runs-on: ubuntu-latest | ||
environment: test | ||
steps: | ||
- | ||
name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- | ||
name: Setup Python environment | ||
uses: actions/setup-python@v4 | ||
- | ||
name: Install Dependencies | ||
run: pip install requests | ||
- | ||
name: Running acceptace test | ||
run: python test.py | ||
env: | ||
ULTRADNS_UNIT_TEST_USERNAME: ${{ secrets.ULTRADNS_UNIT_TEST_USERNAME }} | ||
ULTRADNS_UNIT_TEST_PASSWORD: ${{ secrets.ULTRADNS_UNIT_TEST_PASSWORD }} | ||
ULTRADNS_UNIT_TEST_HOST_URL: ${{ secrets.ULTRADNS_UNIT_TEST_HOST_URL }} | ||
Release_Job: | ||
runs-on: ubuntu-latest | ||
needs: Code_Analysis_Job | ||
environment: prod | ||
steps: | ||
- | ||
name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- | ||
name: Setup Python environment | ||
uses: actions/setup-python@v4 | ||
- | ||
name: Create Release Info | ||
run: echo "RELEASE_VERSION=$(cat .plugin-version)" >> $GITHUB_ENV | ||
- | ||
name: Installing Dependencies | ||
run: | | ||
pip install requests | ||
pip install hatch | ||
- | ||
name: Versioning the build | ||
run: hatch version ${{ env.RELEASE_VERSION }} | ||
- | ||
name: Creating python Package | ||
run: hatch build | ||
- | ||
name: Publishing python Package | ||
uses: pypa/[email protected] | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "ultra-rest-client" | ||
dynamic = ["version"] | ||
description = "A sample Python client for communicating with the UltraDNS REST API" | ||
readme = "README.md" | ||
license-files = { paths = ["LICENSE"] } | ||
authors = [ | ||
{ name = "ultradns", email = "[email protected]" }, | ||
] | ||
keywords = [ | ||
"ultra_rest_client", | ||
] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Topic :: Utilities", | ||
] | ||
dependencies = [ | ||
"requests", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/ultradns/python_rest_api_client" | ||
|
||
[tool.hatch.version] | ||
path = "ultra_rest_client/about.py" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = [ | ||
"/ultra_rest_client", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import ultra_rest_client | ||
import os | ||
import time | ||
|
||
username = os.environ.get('ULTRADNS_UNIT_TEST_USERNAME') | ||
password = os.environ.get('ULTRADNS_UNIT_TEST_PASSWORD') | ||
domain = os.environ.get('ULTRADNS_UNIT_TEST_HOST_URL') | ||
|
||
test_zone_name='udns-python-rest-client-test.com.' | ||
|
||
c = ultra_rest_client.RestApiClient(username, password, False, domain) | ||
print('version %s' % c.version()) | ||
print('status %s' % c.status()) | ||
account_details = c.get_account_details() | ||
account_name = account_details[u'accounts'][0][u'accountName'] | ||
print('account name %s' % account_name ) | ||
print('get zone metadata %s' % c.get_zone_metadata_v3(test_zone_name)) | ||
print('get first 5 primary zones with udns: %s' % c.get_zones_v3(limit=5, sort="NAME", reverse=False, q={"name":"udns", "zone_type":"PRIMARY"})) | ||
print('\n') | ||
print('get first 5 secondary zones: %s' % c.get_zones_v3(limit=5, sort="NAME", reverse=False, q={"zone_type":"SECONDARY"})) | ||
print('\n') | ||
print('get all zones with 25 zones per page. First page is returned by default: %s' % c.get_zones_v3(limit=25, q={"zone_status":"ALL"})) | ||
print('\n') | ||
print('get next page of zones with 25 zones per page. Cursor returned by above request is used: %s' % c.get_zones_v3(limit=25, cursor='MTY1NDUxNTM4MTczMXNiLXN1YnBvb2wtY3J1ZC0xLmNvbS46TkVYVA==', q={"zone_status":"ALL"})) | ||
print('create primary zone result %s' % c.create_primary_zone(account_name, "foo.invalid.")) | ||
print('get zone metadata %s' % c.get_zone_metadata("foo.invalid.")) | ||
print('delete zone %s ' % c.delete_zone("foo.invalid.")) | ||
print('zone name %s ' % test_zone_name) | ||
print('get_rrsets %s ' % c.get_rrsets(test_zone_name)) | ||
print('create_rrset %s ' % c.create_rrset(test_zone_name, "A", "foo", 300, "1.2.3.4")) | ||
print('get_rrsets %s ' % c.get_rrsets(test_zone_name)) | ||
print('get_rrsets_by_type %s ' % c.get_rrsets_by_type(test_zone_name, "A")) | ||
print('edit_rrset %s ' % c.edit_rrset(test_zone_name, "A", "foo", 100, ["10.20.30.40"])) | ||
print('get_rrsets %s ' % c.get_rrsets(test_zone_name)) | ||
print('get_rrsets_by_type %s ' % c.get_rrsets_by_type(test_zone_name, "A")) | ||
print('get_rrsets_by_type_owner %s ' % c.get_rrsets_by_type_owner(test_zone_name, "A", "foo")) | ||
print('delete_rrset %s ' % c.delete_rrset(test_zone_name, "A", "foo")) | ||
print('get_rrsets %s ' % c.get_rrsets(test_zone_name)) | ||
print('get_rrsets_by_type %s ' % c.get_rrsets_by_type(test_zone_name, "A")) | ||
print('get_rrsets_by_type_owner %s ' % c.get_rrsets_by_type_owner(test_zone_name, "A", "foo")) | ||
print('batch delete %s ' % c.batch([ | ||
{'method': 'DELETE', 'uri': '/v1/zones/' + test_zone_name + '/rrsets/A/foo2'}, | ||
{'method': 'DELETE', 'uri': '/v1/zones/' + test_zone_name + '/rrsets/A/foo3'}, | ||
])) | ||
|
||
print('get_rrsets_by_type %s ' % c.get_rrsets_by_type(test_zone_name, "A")) | ||
print('get_rrsets_by_type_owner %s ' % c.get_rrsets_by_type_owner(test_zone_name, "A", "foo2")) | ||
print('batch create %s ' % c.batch([ | ||
{'method': 'POST', 'uri': '/v1/zones/' + test_zone_name + '/rrsets/A/foo2', 'body': {'ttl': 100, 'rdata': ['2.4.6.8']}}, | ||
{'method': 'POST', 'uri': '/v1/zones/' + test_zone_name + '/rrsets/A/foo3', 'body': {'ttl': 100, 'rdata': ['20.40.60.80']}}, | ||
])) | ||
print('get_rrsets_by_type %s ' % c.get_rrsets_by_type(test_zone_name, "A")) | ||
print('get_rrsets_by_type_owner %s ' % c.get_rrsets_by_type_owner(test_zone_name, "A", "foo2")) | ||
print('batch delete %s ' % c.batch([ | ||
{'method': 'DELETE', 'uri': '/v1/zones/' + test_zone_name + '/rrsets/A/foo2'}, | ||
{'method': 'DELETE', 'uri': '/v1/zones/' + test_zone_name + '/rrsets/A/foo3'}, | ||
])) | ||
print('get_rrsets_by_type %s ' % c.get_rrsets_by_type(test_zone_name, "A")) | ||
print('get_rrsets_by_type_owner %s ' % c.get_rrsets_by_type_owner(test_zone_name, "A", "foo2")) | ||
|
||
#getting zones with q, sort, offset, limit | ||
print('get first 5 primary zones with j: %s' % c.get_zones(offset=0, limit=5, sort="NAME", reverse=False, q={"name":"j", "zone_type":"PRIMARY"})) | ||
|
||
#creating a zone with upload | ||
result = c.create_primary_zone_by_upload(account_name, 'sample.client.me.', './zone.txt') | ||
print('create zone via upload: %s' % result) | ||
|
||
# check the task status | ||
while True: | ||
task_status = c.get_task(result['task_id']) | ||
print('task status: %s ' % c.get_task(result['task_id'])) | ||
if task_status['code'] != 'IN_PROCESS': | ||
break | ||
time.sleep(1) | ||
|
||
|
||
#check all task status | ||
print('all task status: %s ' % c.get_all_tasks()) | ||
|
||
#delete task status | ||
print('delete task status: %s ' % c.clear_task(result['task_id'])) | ||
|
||
#delete the zone | ||
print('delete zone: %s ' % c.delete_zone('sample.client.me.')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
__version__="0.0.0" | ||
__prefix__="udns-python-rest-client-" | ||
|
||
def get_client_user_agent() : | ||
return __prefix__+__version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters