Skip to content

Commit aa92811

Browse files
committed
feat: update SDK codebase to replace Go with Python
1 parent 5da175b commit aa92811

File tree

17 files changed

+204
-131
lines changed

17 files changed

+204
-131
lines changed

.github/workflows/release.yaml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,37 @@ name: Generate Next Release
55
on:
66
workflow_dispatch:
77

8+
env:
9+
PACKAGE_DIR: equinix_metal
10+
DIST_DIR: equinix_metal/dist
811
jobs:
912
release:
10-
name: Release
13+
name: Build and publish package
1114
runs-on: ubuntu-latest
15+
1216
steps:
13-
- name: Install Go
14-
uses: actions/setup-go@v5
17+
- name: Install Python
18+
uses: actions/setup-python@v5
1519
with:
16-
go-version: 1.19.x
20+
python-version: 3.8
1721

1822
- name: Checkout
1923
uses: actions/checkout@v4
2024
with:
2125
fetch-depth: 0
2226
ssh-key: ${{ secrets.DEPLOY_KEY }}
2327

24-
- name: Release
28+
- name: Install dependencies
29+
working-directory: ${{ env.PACKAGE_DIR }}
30+
run: |
31+
python -m pip install --upgrade build
32+
33+
- name: Install pyaml for patching script
34+
working-directory: ${{ env.PACKAGE_DIR }}
35+
run: |
36+
python -m pip install pyaml
37+
38+
- name: Create GitHub release
2539
uses: cycjimmy/semantic-release-action@v4
2640
with:
2741
semantic_version: 19.0.5
@@ -36,3 +50,15 @@ jobs:
3650
GIT_COMMITTER_NAME: equinix-labs@auto-commit-workflow
3751
GIT_COMMITTER_EMAIL: [email protected]
3852
RELEASE_REQUESTER: "@${{ github.event.sender.login }}"
53+
54+
- name: Build package
55+
working-directory: ${{ env.PACKAGE_DIR }}
56+
run: |
57+
python -m build --sdist --wheel --outdir dist/ .
58+
59+
- name: Publish package
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+
with:
62+
user: __token__
63+
password: ${{ secrets.PYPI_API_TOKEN }}
64+
packages-dir: ${{ env.DIST_DIR }}

.gitignore

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,67 @@
1-
equinix-metal.swagger.json.orig
2-
.vscode
3-
.DS_Store
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
venv/
48+
.venv/
49+
.python-version
50+
.pytest_cache
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Django stuff:
57+
*.log
58+
59+
# Sphinx documentation
60+
docs/_build/
61+
62+
# PyBuilder
63+
target/
64+
65+
#Ipython Notebook
66+
.ipynb_checkpoints
467
.openapi-generator
5-
.travis.yml
6-
git_push.sh
7-
services/*/api/

.openapi-generator-ignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
setup.py
2+
setup.cfg
3+
# OpenAPI Generator Ignore
4+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
5+
6+
# Use this file to prevent files from being overwritten by the generator.
7+
# The patterns follow closely to .gitignore or .dockerignore.
8+
9+
# As an example, the C# client generator defines ApiClient.cs.
10+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
11+
#ApiClient.cs
12+
13+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
14+
#foo/*/qux
15+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
16+
17+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
18+
#foo/**/qux
19+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
20+
21+
# You can also negate patterns with an exclamation (!).
22+
# For example, you can ignore all files in a docs folder with the file extension .md:
23+
#docs/*.md
24+
# Then explicitly reverse the ignore rule for a single file:
25+
#!docs/README.md

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
Thx for your interest! We're so glad you're here.
33

44
### Important Resources
5-
- bugs: [https://github.com/equinix/equinix-sdk-go/issues](https://github.com/equinix/metal/issues)
5+
- bugs: [https://github.com/equinix/equinix-sdk-python/issues](https://github.com/equinix/metal/issues)
66

77
### Code of Conduct
8-
Available via [https://github.com/equinix/equinix-sdk-go/blob/master/.github/CODE_OF_CONDUCT.md](https://github.com/equinix/metal/blob/master/.github/CODE_OF_CONDUCT.md)
8+
Available via [https://github.com/equinix/equinix-sdk-python/blob/master/.github/CODE_OF_CONDUCT.md](https://github.com/equinix/metal/blob/master/.github/CODE_OF_CONDUCT.md)
99

1010
### Environment Details
11-
[https://github.com/equinix/equinix-sdk-go/blob/master/Makefile](https://github.com/equinix/equinix-sdk-go/blob/master/Makefile)
11+
[https://github.com/equinix/equinix-sdk-python/blob/master/Makefile](https://github.com/equinix/equinix-sdk-python/blob/master/Makefile)
1212

1313
### How to Submit Change Requests
14-
Please submit change requests and / or features via [Issues](https://github.com/equinix/equinix-sdk-go/issues). There's no guarantee it'll be changed, but you never know until you try. We'll try to add comments as soon as possible, though.
14+
Please submit change requests and / or features via [Issues](https://github.com/equinix/equinix-sdk-python/issues). There's no guarantee it'll be changed, but you never know until you try. We'll try to add comments as soon as possible, though.
1515

1616
#### Pull Requests
1717
All command changes must be reflected in the documentation, this includes new commands and changes to options. The documentation is generated via `make generate-docs`.
1818

1919
### How to Report a Bug
20-
Bugs are problems in code, in the functionality of an application or in its UI design; you can submit them through [Issues](https://github.com/equinix/equinix-sdk-go/issues) as well.
20+
Bugs are problems in code, in the functionality of an application or in its UI design; you can submit them through [Issues](https://github.com/equinix/equinix-sdk-python/issues) as well.

DEVELOPMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- `spec/services/<service>/oas3.patched` a directory of the latest patched OpenAPI spec for a single service
99
- `spec/services/<service>/patches/*.patch` patch files to apply against the fetched OpenAPI spec for a single service
1010
- `examples/` hand crafted examples to demonstrate usage
11-
- `services/<service>` generated Go client for a single service
11+
- `equinix/services/<service>` generated Python client for a single service
1212

1313
## Build
1414

@@ -32,9 +32,9 @@ The onboarding proces will automatically attempt to download the spec and genera
3232

3333
## Adding custom openapi-generator templates for a service
3434

35-
This repo uses [`openapi-generator`](https://github.com/OpenAPITools/openapi-generator) to generate Go code. When necessary, we can provide custom templates to the generator in order to change the generated code.
35+
This repo uses [`openapi-generator`](https://github.com/OpenAPITools/openapi-generator) to generate Python code. When necessary, we can provide custom templates to the generator in order to change the generated code.
3636

37-
When a service is onboarded, an empty `templates/services/<service>/` directory is created. To modify generated code, you can put a custom template in this directory. Templates that are known to the generator can be seen here: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/go
37+
When a service is onboarded, an empty `templates/services/<service>/` directory is created. To modify generated code, you can put a custom template in this directory. Templates that are known to the generator can be seen here: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python
3838

3939
Before adding custom templates for a service, review [the `openapi-generator` docs for templating](https://openapi-generator.tech/docs/templating).
4040

Makefile

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
.PHONY: all pull fetch patch generate clean codegen mod docs move-other patch-post fmt test stage
1+
.PHONY: all pull fetch patch generate clean codegen docs move-other patch-post fmt test stage
22

33
CURRENT_UID := $(shell id -u)
44
CURRENT_GID := $(shell id -g)
55

66
GIT_ORG=equinix
7-
GIT_REPO=equinix-sdk-go
7+
GIT_REPO=equinix-sdk-python
88
PACKAGE_VERSION=$(shell cat version)
99
USER_AGENT=${GIT_REPO}/${PACKAGE_VERSION}
1010

11-
OPENAPI_IMAGE_TAG=v7.1.0
11+
OPENAPI_IMAGE_TAG=v7.4.0
1212
OPENAPI_IMAGE=openapitools/openapi-generator-cli:${OPENAPI_IMAGE_TAG}
1313
CRI=docker # nerdctl
1414
OPENAPI_GENERATOR=${CRI} run --rm -u ${CURRENT_UID}:${CURRENT_GID} -v $(CURDIR):/local ${OPENAPI_IMAGE}
1515
SPEC_FETCHER=${CRI} run --rm -u ${CURRENT_UID}:${CURRENT_GID} -v $(CURDIR):/workdir --entrypoint sh mikefarah/yq:4.30.8 script/download_spec.sh
16-
GOLANGCI_LINT=golangci-lint
1716

1817
SPEC_BASE_DIR=spec/services
1918
TEMPLATE_BASE_DIR=templates/services
@@ -27,19 +26,5 @@ generate-all:
2726
make -f $$makefile generate;\
2827
done
2928

30-
mod:
31-
rm -f go.mod go.sum ${PACKAGE_PREFIX}/${PACKAGE_MAJOR}/go.mod ${PACKAGE_PREFIX}/${PACKAGE_MAJOR}/go.sum
32-
go mod init github.com/${GIT_ORG}/${GIT_REPO}
33-
go mod tidy
34-
35-
test:
36-
go test -v ./...
37-
38-
lint:
39-
@$(GOLANGCI_LINT) run -v --no-config --fast=false --fix --disable-all --enable goimports $(PACKAGE_PREFIX)
40-
41-
fmt:
42-
go run mvdan.cc/[email protected] -l -w .
43-
4429
stage:
4530
test -d .git && git add --intent-to-add .

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
# Equinix Go SDK
1+
# Equinix Python SDK
22

33
[![Maintained](https://img.shields.io/badge/stability-maintained-green.svg)](https://github.com/equinix-labs/equinix-labs/blob/main/maintained-statement.md)
4+
[![Release](https://img.shields.io/github/v/release/equinix/equinix-sdk-python)](https://github.com/equinix/equinix-sdk-python/releases/latest)
5+
[![PyPi](https://img.shields.io/pypi/v/equinix-sdk-python)](https://img.shields.io/pypi/v/equinix-sdk-python)
46

5-
This is the official Go SDK for Equinix services. This SDK is currently provided with a major version of [v0](https://blog.golang.org/v2-go-modules). We aim to avoid breaking changes to this library, but they will certainly happen as we work towards a stable v1 library.
7+
This is the official Python SDK for Equinix services. This SDK is currently provided with a major version of `v0`. We aim to avoid breaking changes to this library, but they will certainly happen as we work towards a stable `v1` library.
68

7-
Each Equinix service supported by this SDK is maintained as a separate package that is generated from the OpenAPI specification for that service. If any Equinix service is not supported by this SDK and you would like to see it added, please [submit a change request](CONTRIBUTING.md)
9+
Each Equinix service supported by this SDK is maintained as a separate submodule that is generated from the OpenAPI specification for that service. If any Equinix service is not supported by this SDK and you would like to see it added, please [submit a change request](CONTRIBUTING.md)
810

911
## Installation
1012

11-
To import this library into your Go project:
13+
To import this library into your Python project:
1214

13-
```go
14-
import "github.com/equinix/equinix-sdk-go"
15+
```sh
16+
pip install equinix
1517
```
1618

17-
Download the module with:
19+
In a given Python file, you can then import all available services:
1820

19-
```sh
20-
go get github.com/equinix/equinix-sdk-go
21+
```python
22+
import equinix
23+
```
24+
25+
Or you can import individual services:
26+
27+
```python
28+
from equinix.services import metalv1
2129
```
2230

2331
## Usage
2432

25-
You can see usage of the generated code in the [`examples` directory](https://github.com/equinix/equinix-sdk-go/tree/main/examples).
33+
You can see usage of the generated code in the [`examples` directory](https://github.com/equinix/equinix-sdk-python/tree/main/examples).

config/openapi-generator.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
2-
"apiNameSuffix": "Api",
3-
"isGoSubmodule": true,
2+
"generateSourceCodeOnly": true,
43
"disallowAdditionalPropertiesIfNotPresent": false,
54
"inlineSchemaOptions": {
65
"RESOLVE_INLINE_ENUMS": true
7-
},
8-
"enumClassPrefix": true
6+
}
97
}

go.mod

Lines changed: 0 additions & 11 deletions
This file was deleted.

go.sum

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)