3 Oct 2024
Build APS Solutions with GitHub Copilot
GitHub Copilot has revolutionized the way developers approach coding, offering AI-powered assistance that streamlines development processes and enhances productivity. For those working with Autodesk Platform Services (APS), Copilot can be a game-changer. By leveraging its AI-driven capabilities, developers can quickly generate and fine-tune code to build custom solutions that integrate seamlessly with APS. In this post, we'll explore how you can start using GitHub Copilot while developing your APS applications today.
Signing Up
If you haven't signed up for GitHub Copilot yet, here's how you can do that. After logging into GitHub, go to the main page, and select Try GitHub Copilot free for 30 days.
Next, select your payment plan. As of October 2024, Copilot is available in 3 paid options (with a 30 day trial):
- Individual ($10 per month or $100 per year)
- Business ($19 per user and month)
- Enterprise ($39 per user and month)
To learn more about the individual plans and their features, check out the Pricing page. In this blog post we'll be using the Individual plan.
On the next page you'll be presented with several preference settings. In Suggestions matching public code (duplication detection filter), you can choose whether Copilot should make code suggestions based on public code. You might want to set this option to Allowed in order to benefit from the many APS code samples available publicly. As for the Allow GitHub to use my code snippets from the code editor for product improvements checkbox, this one is currently required, at least under the Individual plan.
After signing up, you can head over to https://github.com/settings/copilot to adjust the preferences, or find additional useful links.
Adding Copilot to Visual Studio Code
Copilot functionality can be accessed in different ways: from your IDE, from the command-line, from a mobile app, and - with Enterprise plans - even from the GitHub website. In this blog post, we'll add Copilot to Visual Studio Code.
With Visual Studio Code open, go to the Extensions sidebar, search for an extension called "GitHub Copilot", and install it.
After that, switch to the Copilot sidebar, and log in with your GitHub credentials.
With that, your Copilot is now ready to use.
Using Copilot in Visual Studio Code
Try using the chat window, and ask Copilot the following question:
How do I generate a 3-legged token for Autodesk Platform Services using its SDK for Node.js?
This is already looking pretty good, wouldn't you say?
Next, create an empty index.js file, and with the cursor inside the file, press Control+I or Command+I, and type in the following prompt:
generate a 2-legged access token for Autodesk Platform Services using their SDK
If you like the code suggested by Copilot, simply hit the Accept button.
With the index.js file still open in the editor, press the Control+I or Command+I one more time, and try the following prompt:
list all objects in an OSS bucket
And here's one more example: try loading one of the existing APS code samples (for example, https://github.com/autodesk-platform-services/aps-simple-viewer-nodejs) into the editor, and use the Copilot Chat to explain what the code in a specific file is doing. In the screenshots below we've picked https://github.com/autodesk-platform-services/aps-simple-viewer-nodejs/blob/develop/services/aps.js.
New APS SDKs?
You may have noticed that the code suggestions above still use forge-apis, the legacy APS SDK that has recently been replaced by the new, modernized SDK. This is not an issue as forge-apis are still supported, however we're looking forward to GitHub Copilot learning about our new SDKs (and making even better code suggestions to you) soon 🙂