Skip to content

feat: Add enterprise Visual Studio subscription licensing APIs - #4483

Open
hariom-hp wants to merge 4 commits into
google:masterfrom
hariom-hp:feat-vss-licensing
Open

feat: Add enterprise Visual Studio subscription licensing APIs#4483
hariom-hp wants to merge 4 commits into
google:masterfrom
hariom-hp:feat-vss-licensing

Conversation

@hariom-hp

@hariom-hp hariom-hp commented Aug 25, 2026

Copy link
Copy Markdown

Summary

Adds typed EnterpriseService support for GitHub Enterprise Cloud's Visual Studio Subscriptions (VSS) licensing endpoints:

  • ListVisualStudioSubscriptions: GET /enterprises/{enterprise}/visual-studio-subscriptions
  • AddOrUpdateVisualStudioSubscriptionAssignment: PUT /enterprises/{enterprise}/visual-studio-subscriptions/{visual_studio_subscription_id}
  • DeleteVisualStudioSubscriptionAssignment: DELETE /enterprises/{enterprise}/visual-studio-subscriptions/{visual_studio_subscription_id}

Changes

  • Defined VisualStudioSubscriptions, VisualStudioSubscriptionAssignment, VisualStudioSubscriptionAssignmentRequest, and ListVisualStudioSubscriptionsOptions.
  • Added the three licensing methods on EnterpriseService with OpenAPI //meta:operation directives and API documentation links.
  • Added unit tests in enterprise_licenses_test.go covering success cases, request body payloads, HTTP 204 responses, bad options, and mock server failures (100% statement coverage).
  • Regenerated accessors in github-accessors.go and iterators in github-iterators.go.

Validation

  • script/fmt.sh
  • script/generate.sh --check
  • script/lint.sh (0 issues across all 12 modules)
  • script/test.sh -race -covermode atomic ./... (0 failures across all 12 modules)
  • go test -v -tags=integration -run=^$ ./test/integration
  • git diff --check

@google-cla

google-cla Bot commented Aug 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Aug 25, 2026
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.52%. Comparing base (27beda9) to head (72eb6bb).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4483   +/-   ##
=======================================
  Coverage   98.51%   98.52%           
=======================================
  Files         195      195           
  Lines       17691    17735   +44     
=======================================
+ Hits        17429    17473   +44     
  Misses        262      262           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @hariom-hp!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @Not-Dhananjay-Mishra

Comment thread github/enterprise_licenses.go Outdated
Comment on lines +94 to +97
Email *string `json:"email,omitempty"`
SubscriptionID *string `json:"subscriptionId,omitempty"`
Username *string `json:"username,omitempty"`
ManualMatch *bool `json:"manual_match,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this doesn't match the schema in docs: email vs visual_studio_subscription_email, subscriptionId vs subscription_id

{
  "type": "object",
  "required": [
    "total_count",
    "visual_studio_subscriptions"
  ],
  "properties": {
    "total_count": {
      "type": "integer"
    },
    "visual_studio_subscriptions": {
      "type": "array",
      "items": {
        "title": "Visual Studio Subscription Assignment",
        "description": "Visual Studio Subscription Assignment",
        "type": "object",
        "properties": {
          "visual_studio_subscription_email": {
            "type": "string",
            "description": "The email associated with the Visual Studio subscription assignment in the visual studio portal."
          },
          "subscription_id": {
            "type": "string",
            "description": "The ID of the Visual Studio Subscription. This is a GUID that comes from the Visual Studio management portal."
          },
          "username": {
            "type": [
              "string",
              "null"
            ],
            "description": "The GitHub username of the user associated with the Visual Studio subscription assignment."
          },
          "manual_match": {
            "type": "boolean",
            "description": "Indicates if the Visual Studio subscription assignment was manually matched to a user."
          }
        }
      }
    }
  }
}

Comment thread github/enterprise_licenses.go Outdated
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/licensing?apiVersion=2022-11-28#add-or-update-a-visual-studio-subscription-user-match
//
//meta:operation PUT /enterprises/{enterprise}/visual-studio-subscriptions/{visual_studio_subscription_id}
func (s *EnterpriseService) AddOrUpdateVisualStudioSubscriptionUserMatch(ctx context.Context, enterprise, subscriptionID string, body VisualStudioSubscriptionUserMatchRequest) (*VisualStudioSubscriptionAssignment, *Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (s *EnterpriseService) AddOrUpdateVisualStudioSubscriptionUserMatch(ctx context.Context, enterprise, subscriptionID string, body VisualStudioSubscriptionUserMatchRequest) (*VisualStudioSubscriptionAssignment, *Response, error) {
func (s *EnterpriseService) AddOrUpdateVisualStudioSubscriptionAssignment(ctx context.Context, enterprise, subscriptionID string, body VisualStudioSubscriptionAssignmentRequest) (*VisualStudioSubscriptionAssignment, *Response, error) {

Comment thread github/enterprise_licenses.go Outdated
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/licensing?apiVersion=2022-11-28#delete-a-visual-studio-subscription-user-match
//
//meta:operation DELETE /enterprises/{enterprise}/visual-studio-subscriptions/{visual_studio_subscription_id}
func (s *EnterpriseService) DeleteVisualStudioSubscriptionUserMatch(ctx context.Context, enterprise, subscriptionID string) (*Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (s *EnterpriseService) DeleteVisualStudioSubscriptionUserMatch(ctx context.Context, enterprise, subscriptionID string) (*Response, error) {
func (s *EnterpriseService) DeleteVisualStudioSubscriptionAssignment(ctx context.Context, enterprise, subscriptionID string) (*Response, error) {

Comment thread github/enterprise_licenses.go Outdated

// VisualStudioSubscriptionUserMatchRequest represents the request body to add or update a user match.
type VisualStudioSubscriptionUserMatchRequest struct {
UserIdentifier string `json:"user_identifier"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
UserIdentifier string `json:"user_identifier"`
UserIdentifier *string `json:"user_identifier,omitempty"`

@hariom-hp

Copy link
Copy Markdown
Author

Thank you for the review, @alexandear

I have addressed all the feedback in the latest commit:

  • Updated JSON field tags in VisualStudioSubscriptionAssignment (visual_studio_subscription_email, subscription_id) and VisualStudioSubscriptions (visual_studio_subscriptions) to align with GitHub's OpenAPI schema.
  • Renamed VisualStudioSubscriptionUserMatchRequest to VisualStudioSubscriptionAssignmentRequest and updated UserIdentifier to *string with omitempty.
  • Renamed the methods to AddOrUpdateVisualStudioSubscriptionAssignment and DeleteVisualStudioSubscriptionAssignment.
  • Regenerated all accessors and iterators via script/generate.sh.
  • Updated unit tests and verified all tests and linters pass cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants