Skip to content

Commit b63583a

Browse files
Decoupled SDK versioning from API version
Some upstream API changes will create breaking SDK changes. As a result, it's necessary to decouple the SDK versioning from the API versioning. Both still follow semantic versioning. We are taking a conservative approach to versioning. The work required to adapt your scripts to new major SDK versions may be minor or even negligible. Please review the changes for the relevant SDK version if interested.
1 parent 8791aa5 commit b63583a

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

.github/workflows/regenerate-library.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
library_version:
66
description: 'The version of the new library'
77
required: true
8+
api_version:
9+
description: 'The corresponding version of the API'
10+
required: true
811

912
jobs:
1013
build:
@@ -26,7 +29,7 @@ jobs:
2629
rm -rf meraki
2730
- name: Regenerate Python Library
2831
run: |
29-
poetry run python generator/generate_library.py -g true -v ${{ github.event.inputs.library_version }} -o ${{ secrets.TEST_ORG_ID }} -k ${{ secrets.TEST_ORG_API_KEY }}
32+
poetry run python generator/generate_library.py -g true -v ${{ github.event.inputs.library_version }} -av ${{ github.event.inputs.api_version }} -o ${{ secrets.TEST_ORG_ID }} -k ${{ secrets.TEST_ORG_API_KEY }}
3033
- name: Set new version for Poetry
3134
run: |
3235
sed -i "s/^version = \".*\"/version = \"${{ github.event.inputs.library_version }}\"/" pyproject.toml
@@ -36,5 +39,5 @@ jobs:
3639
with:
3740
author_name: GitHub Action
3841
author_email: support@meraki.com
39-
message: Automatically regenerated library to version ${{ github.event.inputs.library_version }}.
42+
message: Automatically regenerated library to version ${{ github.event.inputs.library_version }} for API version ${{ github.event.inputs.api_version }}.
4043
new_branch: release

generator/generate_library.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
This script generates the Meraki Python library using either the public OpenAPI specification, or, with an API key & org
1616
ID as inputs, a specific dashboard org's OpenAPI spec.
1717
18-
=== USAGE ===
19-
python[3] generate_library.py [-o <org_id>] [-k <api_key>] [-v <version_number>] [-g <is_called_from_github_action>]
20-
API key can, and is recommended to, be set as an environment variable named MERAKI_DASHBOARD_API_KEY.
21-
"""
18+
=== USAGE === python[3] generate_library.py [-o <org_id>] [-k <api_key>] [-v <version_number>] [-av
19+
<api_version_number>] [-g <is_called_from_github_action>]
20+
21+
API key can, and is recommended to, be set as an environment variable named MERAKI_DASHBOARD_API_KEY."""
2222

2323
REVERSE_PAGINATION = ["getNetworkEvents", "getOrganizationConfigurationChanges"]
2424

@@ -226,7 +226,7 @@ def parse_params(operation: str, parameters: dict, param_filters=None):
226226
return unpack_params(operation, parameters, param_filters)
227227

228228

229-
def generate_library(spec: dict, version_number: str, is_github_action: bool):
229+
def generate_library(spec: dict, version_number: str, api_version_number: str, is_github_action: bool):
230230
# Supported scopes list will include organizations, networks, devices, and all product types.
231231
supported_scopes = [
232232
"organizations",
@@ -295,9 +295,14 @@ def generate_library(spec: dict, version_number: str, is_github_action: bool):
295295
with open(f"meraki/{file}", "w+", encoding="utf-8", newline=None) as fp:
296296
contents = response.text
297297
if file == "__init__.py":
298+
# replace library version
298299
start = contents.find("__version__ = ")
299300
end = contents.find("\n", start)
300301
contents = f"{contents[:start]}__version__ = '{version_number}'{contents[end:]}"
302+
# replace API version
303+
start = contents.find("__api_version__ = ")
304+
end = contents.find("\n", start)
305+
contents = f"{contents[:start]}__api_version__ = '{api_version_number}'{contents[end:]}"
301306
fp.write(contents)
302307

303308
# Organize data from OpenAPI specification
@@ -743,6 +748,7 @@ def main(inputs):
743748
api_key = os.environ.get("MERAKI_DASHBOARD_API_KEY")
744749
org_id = None
745750
version_number = "custom"
751+
api_version_number = "custom"
746752
is_github_action = False
747753

748754
try:
@@ -760,6 +766,8 @@ def main(inputs):
760766
api_key = arg
761767
elif opt == "-v":
762768
version_number = arg
769+
elif opt == "-av":
770+
api_version_number = arg
763771
elif opt == "-g":
764772
if arg.lower() == "true":
765773
is_github_action = True
@@ -795,7 +803,7 @@ def main(inputs):
795803
f'"HTTP GET https://api.meraki.com/api/v1/openapiSpec" is failing.'
796804
)
797805

798-
generate_library(spec, version_number, is_github_action)
806+
generate_library(spec, version_number, api_version_number, is_github_action)
799807

800808

801809
if __name__ == "__main__":

meraki/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from meraki.rest_session import *
4545

4646
__version__ = '1.56.0'
47+
__api_version__ = '1.56.0'
4748

4849

4950
class DashboardAPI(object):

0 commit comments

Comments
 (0)