GithubHelp home page GithubHelp logo

meslubi2021 / postman-api-environments-utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from postmanlabs/postman-api-environments-utils

1.0 0.0 0.0 60 KB

Utilities to manage Postman environments using the Postman API.

License: MIT License

JavaScript 100.00%

postman-api-environments-utils's Introduction

postman-api-environments-utils

This code is part of a blog post and is not actively maintained by Postman.

Examples of utilities to manage Postman environments using the Postman API.

Contents

Shell commands that allow you to solve three different use cases with Postman environments using the Postman API.

All the commands are located in the folder commands.

listEnvsWithVarValue

For a workspace, lists all the environments and variables that contain a specific value.

Example:

➜  listEnvsWithVarValue git:(main) ./listEnvsWithVarValue.js --workspaceId=86d76555-4383-4a6d-aea4-d7c660143f42 --variableValue="token"
Found 8 environments
Found variable "auth" in environment "Stage" (ba2f563e-2557-4d2d-bc0c-07ed98ccc10a) with value "token"
Found variable "token" in environment "Production" (62bc4333-6724-44c0-b2d4-32261f01985e) with value "token"
Found variable "key" in environment "Local" (59b619aa-e136-44a8-8734-45c01e607931) with value "token"
Found 3 variables

mergeEnvironments

Receives a list of environment ids and created a new environment on the specified workspace, that will contain all the different variables (keys) of the source environments. Prints the new environment info on the screen.

Example:

➜  mergeEnvironments git:(main) ./mergeEnvironments.js --workspaceId=86d76555-4383-4a6d-aea4-d7c660143f42 --newEnvironmentName="Merged environment" --environments=16473433-59b619aa-e136-44a8-8734-45c01e607931,16473433-62bc4333-6724-44c0-b2d4-32261f01985e,16473433-ba2f563e-2557-4d2d-bc0c-07ed98ccc10a
Created new environment "Merged environment" with ID af1f16b4-116e-4c5d-be2b-484ca22b9ade and details:
{
  "id": "af1f16b4-116e-4c5d-be2b-484ca22b9ade",
  "name": "Merged environment",
  "owner": "16473433",
  "createdAt": "2023-08-30T13:07:04.000Z",
  "updatedAt": "2023-08-30T13:07:04.000Z",
  "values": [
    {
      "key": "key",
      "value": "token",
      "enabled": true,
      "type": "default"
    },
    {
      "key": "token",
      "value": "token",
      "enabled": true,
      "type": "default"
    },
    {
      "key": "common",
      "value": "value 7",
      "enabled": true,
      "type": "default"
    },
    {
      "key": "auth",
      "value": "token",
      "enabled": true,
      "type": "default"
    }
  ],
  "isPublic": false
}

updateVarByName

Updates the value of all the variables with a specific name of the environments of a workspace with the provided value.

Example:

➜  updateVarByName git:(main) ./updateVarByName.js --workspaceId=86d76555-4383-4a6d-aea4-d7c660143f42 --variableName=common --variableValue="value 7"
Found 8 environments
Processing environment ba2f563e-2557-4d2d-bc0c-07ed98ccc10a
  Updating variable "common" in environment from "value 6" to "value 7"
Processing environment 0a5f9210-1977-4549-96b8-423f94f228cf
Processing environment 53f09c0a-9d0c-464e-9115-a54f8a914a0a
Processing environment 59b619aa-e136-44a8-8734-45c01e607931
  Updating variable "common" in environment from "value 6" to "value 7"
Processing environment 3f8231ee-757e-4d5f-9948-1801a3b4043d
Processing environment 62bc4333-6724-44c0-b2d4-32261f01985e
  Updating variable "common" in environment from "value 6" to "value 7"
Processing environment ac748eb5-6477-421c-93ab-e6df73c284d8
Processing environment 23e27594-48dd-407f-a1d6-c4068e1f0ea5
Updated 3 variables

postman-api-environments-utils's People

Contributors

davidespihernandez avatar david-espi-hernandez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.