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

Generate a Microsoft Graph SDK #4346

Merged
merged 117 commits into from
Sep 17, 2024
Merged

Generate a Microsoft Graph SDK #4346

merged 117 commits into from
Sep 17, 2024

Conversation

manicminer
Copy link
Contributor

@manicminer manicminer commented Aug 5, 2024

Depends on: hashicorp/go-azure-sdk#1058

This PR incorporates various fixes and improvements to both the MS Graph Importer and Go SDK Generator, enabling the generation of a Microsoft Graph SDK.

⚠️ Breaking Changes

  • References to model interfaces in response structs for methods were previously *interface{}, these are now interface{}. This affects Resource Manager and Microsoft Graph SDKs.

Summary of Changes

  • Repository / Tooling

    • Add workflows for MS Graph import + generation
    • Update workflow triggers as we don't need to run every workflow on every change
  • Go SDK Generator

    • Support for generating a Microsoft Graph SDK (and future data plane SDKs with custom base clients)
    • Support for generating Common Types
    • Support for common types in all references (models, options, methods etc)
    • Support for generating OData request options
    • Support for generating nullable model fields using the go-azure-sdk/sdk/nullable types
      • Allows fields to be non-zero, zero-value, explicitly null, or omitted, all at the same time.
    • Implement support for read-only fields
    • Improvements to discriminated models
      • Define a base struct type for parent models
      • Support for unmarshaling parent models directly in methods
      • Output the discriminated field and unmarshal it, instead of hiding it
      • Implement a method on discriminated type interfaces to return a struct for the parent model
      • Embed parent model interfaces where ancestry spans multiple generations
      • Implement fields from all ancestors in child model structs
      • Ability for child models to return standalone representations of any ancestor (enforced by parent interfaces)
    • Output comments for operations
    • Wrap model/operation comments at 120 columns for prettier output
    • Handle arbitrary API version strings in addition to Y-m-d[-preview] convention
    • Add missing imports to generated code, other performance improvements
    • Fix some race conditions
  • MS Graph Importer

    • Update to latest msgraph-metadata submodule
    • Rewrite the model parsing functions to be more selective and opinionated
    • Fully support model inheritence with SDK compatibility in mind
    • Support constant and model references in operations
    • Move all resource IDs into Common Types
    • Clean up the "ById" suffix hack
    • Handle different content types for responses
    • Handle OData headers and request parameters, and other query params
    • Blacklist some resources with irreconcilable paths/IDs
    • Various fixes for casing and singularization/pluralization
    • Improved method naming, particularly around OData functions
    • Support for nullable field types
    • Support for required and read-only fields
    • Generate descriptions for operations and model fields
    • Add @odata.id and @odata.type fields to every model
    • Add an @odata.bind field for DirectoryObject references
    • Remove microsoft.graph. prefix on action URL suffixes
    • Support for discrimination, automatically infer all discriminated models
    • Improved model and constant naming
    • Support for data workarounds in models and constants
      • Add workaround for broken field name in Application model
      • Add workarounds for ConditionalAccessPolicy to enable correct behavior with nullable fields
      • Workaround for invalid resource IDs with repeating segments (which aren't supported)
    • Support for workarounds in service/resource definitions
      • Add workaround for Synchronization Secrets (GET method missing in metadata)

Supported Services

  • Applications
    • Application Management
    • Federated Identity Credentials
    • Synchronization (incl. jobs, secrets, templates)
    • Token Issuance Policy
    • Token Lifetime Policy
  • Application Templates
  • Audit Logs
  • Device Management
  • Directory
    • Administrative Units (incl. extensions, members)
    • Attribute Sets
    • Custom Security Attributes
    • Federation
    • On Premises Sync
    • Subscriptions
  • Directory Objects
  • Directory Roles
  • Directory Role Templates
  • Domains
  • Groups
    • Group Management
    • App Role Assignments
    • OneDrive
    • Permission Grants
    • Teams
  • Identity
    • Authentication Events
    • B2x User Flows
    • Conditional Access
      • Authentication Strength Policies,
      • Named Locations
      • Policies
    • Identity Providers
    • User Flow Attributes
  • Identity Governance
    • Access Reviews
    • App Consent
    • Entitlement Management
      • Access packages
      • Assignments & Policies
      • Requests
      • Catalogs
      • Connected Organizations
      • Resource Environments
      • Resource Requests
      • Resource Roles/Scopes
      • Settings
    • Identity Governance
    • Lifecycle Workflows
    • Privileged Access
    • Terms of Use
  • Invitations
  • "Me"
    • Near-complete API support from various services
  • OAuth2 Permission Grants
  • Policies
    • Activity-based Timeout Policy
    • Admin Consent Request Policy
    • App Management Policy
    • Authentication Flows Policy
    • Authentication Methods Policy
    • Authentication Strength Policy
    • Authorization Policy
    • Claims Mapping Policy
    • Conditional Access Policy
    • Cross Tenant Access Policy
    • Device Registration Policy
    • Feature Rollout Policy
    • Home Realm Discovery Policy
    • Permission Grant Policy
    • Role Management Policy
    • Token Issuance Policy
    • Token Lifetime Policy
  • Reports
    • Authentication Methods
    • Print Usages
    • Partners
    • Security
  • Role Management
    • Directory Roles
    • Assignment Roles
    • Assignment Schedules
    • Role Definitions
    • Role Eligibility
    • Entitlement Management
      • Assignments
      • Definitions
      • Eligibility
  • Schema Extensions
  • Service Principals
    • Service Principal Management
    • App Management Policy
    • App Role Assignments
    • Claims Mapping Policy
    • Federated Identity Credentials
    • Home Realm Discovery Policy
    • OAuth2 Permission Grants
    • Synchronization (incl. jobs, secrets, templates)
    • Token Issuance Policy
    • Token Lifetime Policy
  • Users
    • User Management
    • Activity
    • App Role Assignments
    • Authentication
    • Calendars
    • Chat
    • Contact
    • Employee Experience
    • Events
    • Extensions
    • Insights
    • Licenses
    • Mail
    • Managed Devices
    • OAuth2 Permission Grants
    • OneDrive
    • Online Meetings
    • Outlook
    • Settings
    • Teams
    • Todos

Generated SDK Improvements

Comments for model fields

Screenshot 2024-08-19 at 16 29 38

Comments for operation methods

Screenshot 2024-08-19 at 16 31 44

Nullable fields support

Screenshot 2024-08-19 at 16 46 38

Read-Only fields support

Screenshot 2024-08-19 at 16 32 35

Ability to obtain an ancestor model representation for discriminated models

Screenshot 2024-09-05 at 00 46 55

Screenshot 2024-09-04 at 22 23 00

Support for OData options (headers and query params)

Screenshot 2024-08-19 at 16 44 23

Outstanding Items

… to prevent naming conflicts with annoyingly named models
…on between `/members/$ref` and `/members/{id}/$ref`
@hashicorp hashicorp deleted a comment from github-actions bot Sep 13, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 13, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 13, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 13, 2024
Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks @manicminer LGTM 🍇

…cklist since this is now covered by workarounds
Copy link

Breaking Changes

No Breaking Changes were found 👍

Copy link

Summary of Changes

No Breaking or Non-Breaking Changes were found 👍

Copy link

New Resource ID Segments containing Static Identifiers

No new Resource ID Segments containing Static Identifiers were identified in the set of changes 🤙.

@hashicorp hashicorp deleted a comment from github-actions bot Sep 17, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 17, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 17, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 17, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 17, 2024
@hashicorp hashicorp deleted a comment from github-actions bot Sep 17, 2024
@manicminer manicminer merged commit 03867b0 into main Sep 17, 2024
9 checks passed
@manicminer manicminer deleted the generate-msgraph-sdk branch September 17, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/acceptance-tests area/discriminators Discriminators are interface/implementations area/resource-identification Related to the Identification/Processing of Resources area/resource-ids Related to Resource IDs, Parsers and Formatters go Pull requests that update Go code tool/data-api Issues with the Data API tool/generator-go-sdk Issues with the Go SDK Generator tool/generator-terraform Issues with the Terraform Generator tool/internal-sdk Related to the internal SDK used in this repository `./tools/sdk` tool/msgraph-importer Issues related to the Microsoft Graph importer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants