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

ArmResource illustration #5017

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

ArmResource illustration #5017

wants to merge 1 commit into from

Conversation

pshao25
Copy link
Member

@pshao25 pshao25 commented Aug 23, 2024

Description:

This PR is to give an intuitive example to handle the problem in:

It contains:

  1. A simple example under test\TestProjects\AgrifoodAsExample-TypeSpec, which prints
  • test\TestProjects\AgrifoodAsExample-TypeSpec\resource.json, the result coming from getArmResources. In this simple case, the output result is pretty much how .net understands resource.
  • test\TestProjects\AgrifoodAsExample-TypeSpec\src\Generated, the generated SDK from tsp spec under the project folder. Each resource will generate 3 classes: XXXCollection, XXXData, XXXResource as below shows.
    image
  1. A simplified example for multi-path resource under test\TestProjects\OneModelInTwoResources, which contains
  • test\TestProjects\OneModelInTwoResources\src\OneModelInTwoResoureces.json, the input swagger
  • test\TestProjects\OneModelInTwoResources\src\Generated, the generated SDK from swagger

For all of above, see the detailed comments in PR.

@@ -0,0 +1,156 @@
[
Copy link
Member Author

Choose a reason for hiding this comment

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

This file is printed from API getArmResources. It takes all the tsp spec under the same folder as input.


/// <summary> Gets the data representing this Feature. </summary>
/// <exception cref="InvalidOperationException"> Throws if there is no data loaded in the current instance. </exception>
public virtual DataConnectorData Data
Copy link
Member Author

Choose a reason for hiding this comment

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

XXXResource contains XXXData as model and corresponding operations.


/// <summary> Gets the data representing this Feature. </summary>
/// <exception cref="InvalidOperationException"> Throws if there is no data loaded in the current instance. </exception>
public virtual SiteData Data
Copy link
Member Author

Choose a reason for hiding this comment

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

SiteResource contains the SiteData as its resource model.


/// <summary> Gets the data representing this Feature. </summary>
/// <exception cref="InvalidOperationException"> Throws if there is no data loaded in the current instance. </exception>
public virtual SiteData Data
Copy link
Member Author

Choose a reason for hiding this comment

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

SiteSlotResource also contains SiteData as its resource model.

Copy link
Member

Choose a reason for hiding this comment

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

so maybe we could rename this file to tspResources.json to align with tspCodeModel
and the same prefix will let github to list the two files side by side


export async function $onEmit(context: EmitContext<AzureNetEmitterOptions>) {
const program: Program = context.program;
const options = resolveAzureEmitterOptions(context);
/* set the loglevel. */
Logger.initialize(program, options.logLevel ?? LoggerLevel.INFO);

const details = getArmResources(program);
Copy link
Member

Choose a reason for hiding this comment

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

maybe we could put this into our agenda and do it first, so that we could have the full codeModel available right here, and we do not have to emit another file, but we could emit an extra section in the tspCodeModel.json

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

Successfully merging this pull request may close these issues.

2 participants