Skip to main content
Skip table of contents

Generating Client Code for PeerGFS API with Swagger.io

Applies to PeerGFS v6.1.0 and later

What is Client Code and How Can Swagger.io Help?

When you interact with the PeerGFS API, client code is the software that enables your application to send requests and receive responses over the network. It refers to the software components or scripts that enable your application to communicate with the API. Client code automates several key tasks:

  • Sending requests to the API: Constructs HTTP requests (such as GET, POST, DELETE) to interact with resources such as jobs, backups, or other system entities.

  • Handling responses from the API: Processes responses, typically in JSON format, to extract relevant data or confirm actions.

  • Automating tasks: Once integrated into your application, client code helps automate tasks such as job management, data synchronization, and system monitoring.

To simplify client code creation, various tools are available that can generate it automatically in multiple programming languages, such as Python, Java, and C#. One such tool is Swagger.io , which provides components such as Swagger Editor and Swagger UI to assist with designing, testing, and documenting APIs. Swagger.io also supports code generation, ensuring that your client code is well-structured and compatible with the PeerGFS API.

Overview of Swagger.io and Client Code Generation

Swagger.io, a platform under the OpenAPI Initiative, provides a suite of tools to design, build, document, and consume RESTful APIs. It utilizes the OpenAPI standard, which defines the structure and behavior of APIs in both human-readable and machine-readable formats.

  • Swagger Editor: A tool for creating and editing API specifications in the OpenAPI format. With Swagger Editor, you can define the endpoints and responses of your API, including the PeerGFS API, in a standardized way. It also allows you to take the PeerGFS API definition file and generate client code in various programming languages (e.g., Python, Java, C#) directly from the Swagger Editor web interface.

  • Swagger UI: A web-based GUI that provides an intuitive interface for creating and editing API specifications. It also offers a live preview of the API documentation.

  • Swagger Codegen: A tool that generates client code in multiple programming languages based on an API definition (e.g., a YAML file) created in Swagger Editor. This client code can be directly integrated into your existing scripts or applications for automating interactions with the PeerGFS API, such as managing jobs, backups, or data synchronization. This reduces the complexity of handling API requests and responses manually.


Steps to Build Client Code for the PeerGFS API

To integrate the PeerGFS API into your application, follow these steps to generate client code using Swagger.io. This process will help you automate interactions with the API, such as managing jobs and backups, by providing ready-to-use code in your preferred programming language.

  1. Download the API YAML File:

    • Open a web browser and navigate to the PMC server on TCP port 8442.

    • Select and download the api.yaml file from the top of the page.

      1-Client Code.png
  2. Access the Swagger Editor:

  3. Import the YAML File:

    • In the Swagger Editor, select Import File from the File menu.

      3-Client Code.png

      The PeerGFS API appears in the Swagger Editor.

      4-Client Code.png
  4. Generate Client Code:

    • In the Swagger editor, click Generate Client, and then select the the programming language for the generated code.

      5-Client Code.png
  5. Download and Integrate the Code:

    • Once code generation is complete, a ZIP file containing the client code will be automatically downloaded.

    • Extract the ZIP file and integrate the generated files into your existing codebase as needed.

      6-Client Code.png

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.