From df3f32bda654e4838c512bf293ac610062a1ba9f Mon Sep 17 00:00:00 2001 From: Muhammad Sufyan Date: Fri, 22 Sep 2023 11:57:40 +0500 Subject: [PATCH 1/4] ci(release-workflow): updates release workflow (#25) This commit updates the release workflow, removes the title field from the input, and updates the run-name for the action. --- .github/workflows/publish.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c4089f1..a0ee979 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,16 +1,11 @@ name: Publish Package - +run-name: Publishing Package Version ${{ github.event.inputs.Version }} on: workflow_dispatch: inputs: Version: - description: "Version to be released in format: x.y.z, where x => major version, y => minor version and z => patch version" - required: true - default: "0.1.0" - Title: - description: "Title of the release" + description: "This input field requires version in format: x.y.z, where x => major version, y => minor version and z => patch version" required: true - default: "Improving API developer experience" jobs: publish-package: @@ -48,5 +43,5 @@ jobs: uses: ncipollo/release-action@v1 with: tag: ${{ steps.tag_version.outputs.new_tag }} - name: Release ${{ github.event.inputs.Title }} + name: Release Version ${{ github.event.inputs.Version }} body: ${{ steps.tag_version.outputs.changelog }} From 68e783817a2256be9a4b3b82f7b8b668a10cf286 Mon Sep 17 00:00:00 2001 From: Usama Bin Tariq <31243495+usamabintariq@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:14:12 +0500 Subject: [PATCH 2/4] ci: add release notification (#26) --- .github/workflows/release-notification.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/release-notification.yml diff --git a/.github/workflows/release-notification.yml b/.github/workflows/release-notification.yml new file mode 100644 index 0000000..0df79f7 --- /dev/null +++ b/.github/workflows/release-notification.yml @@ -0,0 +1,19 @@ +name: Release Notification + +on: + release: + types: [released] + +jobs: + send-slack-notification: + runs-on: ubuntu-latest + timeout-minutes: 2 + steps: + - name: Send slack notification + id: slack + uses: slackapi/slack-github-action@v1.25.0 + with: + channel-id: 'C012YFE3D6D' + slack-message: "core-interfaces-python release has been triggered!" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} From c9c22ed2c4b284c1c39186dbe5bf9e83b6c6661f Mon Sep 17 00:00:00 2001 From: Hamza Mahmood Date: Tue, 2 Apr 2024 15:09:55 +0500 Subject: [PATCH 3/4] ci: merge release notification action (#27) --- .github/workflows/publish.yml | 14 ++++++++++++++ .github/workflows/release-notification.yml | 19 ------------------- 2 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 .github/workflows/release-notification.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a0ee979..e61a6cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,20 +16,24 @@ jobs: contents: write steps: - uses: actions/checkout@v3 + - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.x" + - name: Build source and wheel distributions run: | python -m pip install --upgrade build twine python -m build twine check --strict dist/* + - name: Publish distribution to PyPI id: release uses: pypa/gh-action-pypi-publish@v1.5.1 with: password: ${{ secrets.PYPI_TOKEN }} + - name: Create tag if: steps.release.outputs.exit_code == 0 id: tag_version @@ -38,6 +42,7 @@ jobs: github_token: ${{ secrets.TAGS_TOKEN }} custom_tag: ${{ github.event.inputs.Version }} tag_prefix: "" + - name: Create changelog for the release if: steps.release.outputs.exit_code == 0 uses: ncipollo/release-action@v1 @@ -45,3 +50,12 @@ jobs: tag: ${{ steps.tag_version.outputs.new_tag }} name: Release Version ${{ github.event.inputs.Version }} body: ${{ steps.tag_version.outputs.changelog }} + + - name: Send slack notification + id: slack + uses: slackapi/slack-github-action@v1.25.0 + with: + channel-id: 'C012YFE3D6D' + slack-message: "core-interfaces-python release has been triggered!" + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-notification.yml b/.github/workflows/release-notification.yml deleted file mode 100644 index 0df79f7..0000000 --- a/.github/workflows/release-notification.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Release Notification - -on: - release: - types: [released] - -jobs: - send-slack-notification: - runs-on: ubuntu-latest - timeout-minutes: 2 - steps: - - name: Send slack notification - id: slack - uses: slackapi/slack-github-action@v1.25.0 - with: - channel-id: 'C012YFE3D6D' - slack-message: "core-interfaces-python release has been triggered!" - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} From 8e924ee23983e166fc412b6054c99f53f5d0264d Mon Sep 17 00:00:00 2001 From: Muhammad Sufyan Date: Fri, 10 May 2024 14:35:09 +0500 Subject: [PATCH 4/4] feat(logging): add interfaces for logging feature (#29) This commit adds interfaces for logging features used for logging the request & response (the implementation will be either NoneSdkLogger or SdkLogger) and also an abstract of logging a particular message that would be implemented by SDK users or the default logger (i.e. ConsoleLogger in our case). --- README.md | 3 ++- apimatic_core_interfaces/__init__.py | 3 ++- apimatic_core_interfaces/logger/__init__.py | 4 +++ apimatic_core_interfaces/logger/api_logger.py | 25 +++++++++++++++++++ apimatic_core_interfaces/logger/logger.py | 19 ++++++++++++++ setup.py | 2 +- 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 apimatic_core_interfaces/logger/__init__.py create mode 100644 apimatic_core_interfaces/logger/api_logger.py create mode 100644 apimatic_core_interfaces/logger/logger.py diff --git a/README.md b/README.md index 8f37182..dd41b32 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ pip install apimatic-core-interfaces | [`ResponseFactory`](apimatic_core_interfaces/factories/response_factory.py) | To convert the client-adapter response into a custom HTTP response | | [`Authentication`](apimatic_core_interfaces/types/authentication.py) | To setup methods for the validation and application of the required authentication scheme | | [`UnionType`](apimatic_core_interfaces/types/union_type.py) | To setup methods for the validation and deserialization of OneOf/AnyOf union types | - +| [`Logger`](apimatic_core_interfaces/logger/logger.py) | An interface for the generic logger facade | +| [`ApiLogger`](apimatic_core_interfaces/logger/api_logger.py) | An interface for logging API requests and responses | ## Enumerations | Name | Description | diff --git a/apimatic_core_interfaces/__init__.py b/apimatic_core_interfaces/__init__.py index 225a1c8..94e6598 100644 --- a/apimatic_core_interfaces/__init__.py +++ b/apimatic_core_interfaces/__init__.py @@ -1,5 +1,6 @@ __all__ = [ 'client', 'factories', - 'types' + 'types', + 'logger' ] \ No newline at end of file diff --git a/apimatic_core_interfaces/logger/__init__.py b/apimatic_core_interfaces/logger/__init__.py new file mode 100644 index 0000000..4e1589c --- /dev/null +++ b/apimatic_core_interfaces/logger/__init__.py @@ -0,0 +1,4 @@ +__all__=[ + "api_logger", + "logger" +] \ No newline at end of file diff --git a/apimatic_core_interfaces/logger/api_logger.py b/apimatic_core_interfaces/logger/api_logger.py new file mode 100644 index 0000000..34ba62d --- /dev/null +++ b/apimatic_core_interfaces/logger/api_logger.py @@ -0,0 +1,25 @@ +from abc import abstractmethod + +class ApiLogger: + """An interface for logging API requests and responses. + + This class should not be instantiated but should be used as a base class + for API Logger classes.""" + + @abstractmethod + def log_request(self, http_request): + """Logs the given HTTP request. + + Args: + http_request (HttpRequest): The HTTP request to log. + """ + ... + + @abstractmethod + def log_response(self, http_response): + """Logs the given HTTP response. + + Args: + http_response (HttpRequest): The HTTP request to log. + """ + ... \ No newline at end of file diff --git a/apimatic_core_interfaces/logger/logger.py b/apimatic_core_interfaces/logger/logger.py new file mode 100644 index 0000000..1090f66 --- /dev/null +++ b/apimatic_core_interfaces/logger/logger.py @@ -0,0 +1,19 @@ +from abc import abstractmethod + + +class Logger: + """An interface for the generic logger facade. + + This class should not be instantiated but should be used as a base class + for Logger classes.""" + + @abstractmethod + def log(self, level, message, params): + """Logs a message with a specified log level and additional parameters. + + Args: + level (int): The log level of the message. + message (str): The message to log. + params (dict): Additional parameters to include in the log message. + """ + ... \ No newline at end of file diff --git a/setup.py b/setup.py index 3a2a13f..ab9bf32 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='apimatic-core-interfaces', - version='0.1.4', + version='0.1.5', description='An abstract layer of the functionalities provided by apimatic-core-library, requests-client-adapter ' 'and APIMatic SDKs.', long_description=long_description,