Package: paconn
Microsoft Power Platform Connectors CLI[Note]These release notes describe functionality that may not have been released yet.To see when this functionality is planned to release, please reviewWhat's new and planned for Common Data Model and Data Integration. Delivery timelines and projected functionality may change or may not ship (seeMicrosoft policy).Thepaconncommand-line tool is designed to aid Microsoft Power Platform custom connectors development.InstallingInstall Python 3.5+ from [https://www.python.org/downloads](Python downloads). Select the 'Download' link on any version of Python greater than Python 3.5. For Linux and macOS X, follow the appropriate link on the page. You can also install using an OS-specific package manager of your choice.Run the installer to begin installation and be sure to check the box 'Add Python X.X to PATH'.Make sure the installation path is in the PATH variable by running:python --versionAfter python is installed, installpaconnby running:pip install paconnIf you get errors saying 'Access is denied', consider using the--useroption or running the command as an Administrator (Windows).Custom Connector Directory and FilesA custom connector consists of two to four files: an Open API swagger definition, an API properties file, an optional icon for the connector, and an optional csharp script file. The files are generally located in a directory with the connector ID as the name of the directory.Sometimes, the custom connector directory may include asettings.jsonfile. Although this file isn't part of the connector definition, it can be used as an argument-store for the CLI.API Definition (Swagger) FileThe API definition file describes the API for the custom connector using the OpenAPI specification. It's also known as the swagger file. For more information about API definitions used to write custom connector, go toCreate a custom connector from an OpenAPI definition. Also review the tutorial in theExtend an OpenAPI definition for a custom connectorarticle.API Properties FileThe API properties file contains some properties for the custom connector. These properties aren't part of the API definition. It contains information such as the brand color, authentication information, and so on. A typical API properties file looks like the following sample:{"properties":{"capabilities":[],"connectionParameters":{"api_key":{"type":"securestring","uiDefinition":{"constraints":{"clearText":false,"required":"true","tabIndex":2},"description":"The KEY for this API","displayName":"KEY","tooltip":"Provide your KEY"}}},"iconBrandColor":"#007EE6","scriptOperations":["getCall","postCall","putCall"],"policyTemplateInstances":[{"title":"MyPolicy","templateId":"setqueryparameter","parameters":{"x-ms-apimTemplateParameter.name":"queryParameterName","x-ms-apimTemplateParameter.value":"queryParameterValue","x-ms-apimTemplateParameter.existsAction":"override"}}]}}More information on each of the properties is given below:properties: The container for the information.connectionParameters: Defines the connection parameter for the service.iconBrandColor: The icon brand color in HTML hex code for the custom connector.scriptOperations: A list of the operations that are executed with the script file. An empty scriptOperations list indicates that all operations are executed with the script file.capabilities: Describes the capabilities for the connector, for example, cloud only, on-prem gateway, and so on.policyTemplateInstances: An optional list of policy template instances and values used in the custom connector.Icon FileThe icon file is a small image representing the custom connector icon.Script FileThe script is a CSX script file that is deployed for the custom connector and executed for every call to a subset of the connector's operations.Settings FileInstead of providing the arguments in the command line, asettings.jsonfile can be used to specify them. A typicalsettings.jsonfile looks like the following sample:{"connectorId":"CONNECTOR-ID","environment":"ENVIRONMENT-GUID","apiProperties":"apiProperties.json","apiDefinition":"apiDefinition.swagger.json","icon":"icon.png","script":"script.csx","powerAppsApiVersion":"2016-11-01","powerAppsUrl":"https://api.powerapps.com"}In the settings file, the following items are expected. If an option is missing but required, the console will prompt for the missing information.connectorId: The connector ID string for the custom connector. This parameter is required for download and update operations, but not for the create or validate operation. A new custom connector with the new ID will be created for create command. If you need to update a custom connector just created using the same settings file, please make sure the settings file is correctly updated with the new connector ID from the create operation.environment: The environment ID string for the custom connector. This parameter is required for all operations, except the validate operation.apiProperties: The path to the API propertiesapiProperties.jsonfile. It's required for the create and update operation. When this option is present during the download, the file will be downloaded to the given location, otherwise it will be saved asapiProperties.json.apiDefinition: The path to the swagger file. It's required for the create, update, and validate operations. When this option is present during the download operation, the file in the given location will be written to, otherwise it will be saved asapiDefinition.swagger.json.icon: The path to the optional icon file. The create and update operations will use the default icon when this parameter is no specified. When this option is present during the download operation, the file in the given location will be written to, otherwise it will be saved asicon.png.script: The path to the optional script file. The create and update operations will use only the value within the specified parameter. When this option is present during the download operation, the file in the given location will be written to, otherwise it will be saved asscript.csx.powerAppsUrl: The API URL for Power Apps. This parameter is optional and set tohttps://api.powerapps.comby default.powerAppsApiVersion: The API version to use for Power Apps. This parameter is optional and set to2016-11-01by default.Command-Line OperationsLoginLog in to Power Platform by running:paconn loginThis command will ask you to log in using the device code login process. Follow the prompt for the log in. Service Principle authentication is not supported at this point. Please reviewa customer workaround posted in the issues page.LogoutLogout by running:paconn logoutDownload Custom Connector FilesThe connector files are always downloaded into a subdirectory with the connector ID as the directory name. When a destination directory is specified, the subdirectory will be created in the specified one. Otherwise, it will be created in the current directory. In addition to the three connector files, the download operation will also write a fourth file called settings.json containing the parameters used to download the files.Download the custom connector files by running:paconn downloadorpaconn download -e [Power Platform Environment GUID] -c [Connector ID]orpaconn download -s [Path to settings.json]When the environment or connector ID isn't specified, the command will prompt for the missing argument(s). The command will output the download location for the connector if it successfully downloads.All the arguments can be also specified using asettings.json file.Arguments
   --cid -c       : The custom connector ID.
   --dest -d      : Destination directory.
   --env -e       : Power Platform environment GUID.
   --overwrite -w : Overwrite all the existing connector and settings files.
   --pau -u       : Power Platform URL.
   --pav -v       : Power Platform API version.
   --settings -s  : A settings file containing required parameters.
                    When a settings file is specified some command 
                    line parameters are ignored.Create a New Custom ConnectorA new custom connector can be created from the connectors files by running thecreateoperation. Create a connector by running:paconn create --api-prop [Path to apiProperties.json] --api-def [Path to apiDefinition.swagger.json]orpaconn create -e [Power Platform Environment GUID] --api-prop [Path to apiProperties.json] --api-def [Path to apiDefinition.swagger.json] --icon [Path to icon.png] --secret [The OAuth2 client secret for the connector]orpaconn create -s [Path to settings.json] --secret [The OAuth2 client secret for the connector]When the environment isn't specified, the command will prompt for it. However, the API definition and API properties file must be provided as part of the command line argument or a settings file. The OAuth2 secret must be provided for a connector using OAuth2. The command will print the connector ID for the newly created custom connector on successful completion. If you're using a settings.json file for the create command, please make sure to update it with the new connector ID before you update the newly created connector.Arguments
   --api-def     : Location for the Open API definition JSON document.
   --api-prop    : Location for the API properties JSON document.
   --env -e      : Power Platform environment GUID.
   --icon        : Location for the icon file.
   --script -x   : Location for the script file.
   --pau -u      : Power Platform URL.
   --pav -v      : Power Platform API version.
   --secret -r   : The OAuth2 client secret for the connector.
   --settings -s : A settings file containing required parameters.
                   When a settings file is specified some command 
                   line parameters are ignored.Update an Existing Custom ConnectorLike thecreateoperation, an existing custom connector can be updated using theupdateoperation. Update a connector by running:paconn update --api-prop [Path to apiProperties.json] --api-def [Path to apiDefinition.swagger.json]orpaconn update -e [Power Platform Environment GUID] -c [Connector ID] --api-prop [Path to apiProperties.json] --api-def [Path to apiDefinition.swagger.json] --icon [Path to icon.png] --secret [The OAuth2 client secret for the connector]orpaconn update -s [Path to settings.json] --secret [The OAuth2 client secret for the connector]When environment or connector ID isn't specified, the command will prompt for the missing argument(s). However, the API definition and API properties file must be provided as part of the command-line argument or a settings file. The OAuth2 secret must be provided for a connector using OAuth2. The command will print the updated connector ID on successful completion. If you're using a settings.json file for the update command, make sure the correct environment and connector ID are specified.Arguments
   --api-def     : Location for the Open API definition JSON document.
   --api-prop    : Location for the API properties JSON document.
   --cid -c      : The custom connector ID.
   --env -e      : Power Platform environment GUID.
   --icon        : Location for the icon file.
   --script -x   : Location for the script file.
   --pau -u      : Power Platform URL.
   --pav -v      : Power Platform API version.
   --secret -r   : The OAuth2 client secret for the connector.
   --settings -s : A settings file containing required parameters.
                   When a settings file is specified some command 
                   line parameters are ignored.Validate a Swagger JSONThe validate operation takes a swagger file and verfies if it follows all the recommended rules. Validate a swagger file by running:paconn validate --api-def [Path to apiDefinition.swagger.json]orpaconn validate -s [Path to settings.json]The command will print the error, warning, or success message depending result of the validation.Arguments
   --api-def     : Location for the Open API definition JSON document.
   --pau -u      : Power Platform URL.
   --pav -v      : Power Platform API version.
   --settings -s : A settings file containing required parameters.
                   When a settings file is specified some command 
                   line parameters are ignored.Best PracticeDownload all of your connectors and use git or any other source code management system to save the files. In case of an incorrect update, redeploy the connector by rerunning the update command with the correct set of files from the source code management system.Please test the custom connector and the settings file in a test environment before deploying in the production environment. Always double check that the environment and connector id are correct.LimitationsThe project is limited to creation, update, and download of a custom connector in the Power Automate and Power Apps environment. When an environment isn't specified, only the Power Automate environments are listed to choose from. For a non-custom connector, the swagger file isn't returned.Stack Owner Property & apiProperties file:Currently, there is a limitation that prevents you from updating your connector's artificats in your environment using Paconn when thestackOwnerproperty is present in yourapiProperties.jsonfile. As a workaround to this, create two versions of your connector artifacts: the first being the version that is submitted to certification and contains thestackOwnerproperty, the second having thestackOwnerproperty omitted to enable updating within your environment. We are working to remove the limitation and will update this section once complete.Reporting issues and feedbackIf you encounter any bugs with the tool, submit an issue in theIssuessection of our GitHub repo.If you believe you have found a security vulnerability that meetsMicrosoft's definition of a security vulnerability, submit areport to MSRC. More information can be found atMSRC frequently asked questions on reporting.ContributingThis project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visithttps://cla.microsoft.com.To contibute a connector to the open source repo, please start by creating a fork on the github repo.
Once you have the fork created, create a new branch on the forked repo. Clone this forked repo on you
local machine, and checkout the branch. Create a folder for your connector under theconnectorsfolder
and place the connector files in the sub-folder. Commit and push the changes to your forked branch.
Create a pull request from the forked branch to the main repo to merge your changes into the main repo.Please see this document for more information.When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.This project has adopted theMicrosoft Open Source Code of Conduct.
For more information see theCode of Conduct FAQor
contactopencode@microsoft.comwith any additional questions or comments.Legal NoticesMicrosoft and any contributors grant you a license to the Microsoft documentation and other content
in this repository under theCreative Commons Attribution 4.0 International Public License,
see theLICENSEfile, and grant you a license to any code in the repository under theMIT License, see theLICENSE-CODEfile.Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation
may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries.
The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks.
Microsoft's general trademark guidelines can be found athttp://go.microsoft.com/fwlink/?LinkID=254653.Privacy information can be found athttps://privacy.microsoft.com/en-us/Microsoft and any contributors reserve all others rights, whether under their respective copyrights, patents,
or trademarks, whether by implication, estoppel or otherwise.LicenseMicrosoft Power Platform Connectors CLI (paconn)

Copyright (c) Microsoft Corporation
All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.