Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2702/expose new btp destination creation #2799

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

longieirl
Copy link
Contributor

Fix for #2702

Requires a newer version of bas-sdk to be published for the token exchange flow to work.

@longieirl longieirl self-assigned this Jan 20, 2025
Copy link

changeset-bot bot commented Jan 20, 2025

🦋 Changeset detected

Latest commit: 2540d98

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@sap-ux/btp-utils Minor
@sap-ux/abap-deploy-config-inquirer Patch
@sap-ux/abap-deploy-config-sub-generator Patch
@sap-ux/adp-tooling Patch
@sap-ux/app-config-writer Patch
@sap-ux/axios-extension Patch
@sap-ux/backend-proxy-middleware Patch
@sap-ux/cf-deploy-config-inquirer Patch
@sap-ux/cf-deploy-config-writer Patch
@sap-ux/deploy-config-generator-shared Patch
@sap-ux/deploy-tooling Patch
@sap-ux/environment-check Patch
@sap-ux/fiori-generator-shared Patch
@sap-ux/flp-config-inquirer Patch
@sap-ux/inquirer-common Patch
@sap-ux/nodejs-utils Patch
@sap-ux/odata-service-inquirer Patch
@sap-ux/preview-middleware Patch
@sap-ux/reload-middleware Patch
@sap-ux/system-access Patch
@sap-ux/telemetry Patch
@sap-ux/odata-cli Patch
@sap-ux/generator-simple-fe Patch
@sap-ux/create Patch
@sap-ux/flp-config-sub-generator Patch
@sap-ux/cf-deploy-config-sub-generator Patch
@sap-ux/cap-config-writer Patch
@sap-ux/fiori-elements-writer Patch
@sap-ux/fiori-freestyle-writer Patch
@sap-ux/ui5-library-reference-sub-generator Patch
@sap-ux/ui5-library-sub-generator Patch
@sap-ux/ui5-application-inquirer Patch
@sap-ux/ui5-library-inquirer Patch
@sap-ux/ui5-library-reference-inquirer Patch
@sap-ux/abap-deploy-config-writer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@longieirl
Copy link
Contributor Author

Change has been merged into bas-sdk, waiting on release https://www.npmjs.com/package/@sap/bas-sdk?activeTab=versions v3.11.2 or higher to consume the changes.

@longieirl longieirl force-pushed the 2702/expose-new-btp-destination-creation branch from ee6a8be to 86dd1b2 Compare January 21, 2025 15:28
@longieirl longieirl removed the blocked label Jan 22, 2025
@longieirl longieirl marked this pull request as ready for review January 22, 2025 10:06
Copy link
Member

@devinea devinea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes to support destination creation looks good.
Changeset ✅
Did not test locally.

Copy link
Contributor

@IainSAP IainSAP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please add some info/code for a failed call, where for example the API could not be executed (not available or no permissions) and the dest name is not returned?

* @param logger Logger
* @returns name representing the newly created SAP BTP destination
*/
export async function createOAuth2UserTokenExchangeDest(
Copy link
Contributor

@IainSAP IainSAP Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the result for a consumer of this API when something fails? Should you throw or document what is returned in this case please?

serviceInstanceName,
logger
);
await destinations.createDestination(basSDKDestination);
Copy link
Contributor

@IainSAP IainSAP Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead return the new destination? This call appears to throw so it would be good to catch and doc what the errors mean so consumers can use this to code against and not have to dig into the underlying APIs...


if (!destinationInstance) {
// Create a new abap-cloud destination instance on the target CF subaccount
await apiCreateServiceInstance('destination', 'lite', DESTINATION_INSTANCE_NAME, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the destination not returned here?

);
await destinations.createDestination(basSDKDestination);
logger?.debug(`SAP BTP destination ${JSON.stringify(basSDKDestination, null, 2)} created.`);
return basSDKDestination.name;
Copy link
Contributor

@IainSAP IainSAP Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you not return the whole Destination object for better usability and consumer wont need to make more API calls subsequently to fetch the destination?

DestinationType
} from './destination';
import type { ServiceInfo } from './service-info';
import { destinations } from '@sap/bas-sdk';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disambiguation :

Suggested change
import { destinations } from '@sap/bas-sdk';
import { destinations as destinationAPI } from '@sap/bas-sdk';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants