google-api-go-client: rename odd version names like admin/directory_v1. This fixes issue #78. Change-Id: I8808c1fe62681a5d914df633c5ac6a7a71a73731 Reviewed-on: https://code-review.googlesource.com/3261 Reviewed-by: Andrew Gerrand <adg@google.com>
diff --git a/admin/directory_v1/admin-api.json b/admin/directory/v1/admin-api.json similarity index 99% rename from admin/directory_v1/admin-api.json rename to admin/directory/v1/admin-api.json index 8289fdd..034ec9f 100644 --- a/admin/directory_v1/admin-api.json +++ b/admin/directory/v1/admin-api.json
@@ -1,12 +1,12 @@ { "kind": "discovery#restDescription", - "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/QlXkTp8arWMqhMMilmdrbkzNu_E\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/uQEY1lxUpBjGfWxd7mioMh_V8P8\"", "discoveryVersion": "v1", "id": "admin:directory_v1", "name": "admin", "canonicalName": "directory", "version": "directory_v1", - "revision": "20150326", + "revision": "20150720", "title": "Admin Directory API", "description": "The Admin SDK Directory API lets you view and manage enterprise resources such as users and groups, administrative notifications, security features, and more.", "ownerDomain": "google.com", @@ -614,6 +614,10 @@ "type": "object", "description": "JSON template for Mobile Device resource in Directory API.", "properties": { + "adbStatus": { + "type": "boolean", + "description": "Adb (USB debugging) enabled or disabled on device (Read-only)" + }, "applications": { "type": "array", "description": "List of applications installed on Mobile Device", @@ -659,6 +663,10 @@ "type": "string", "description": "The default locale used on the Mobile Device (Read-only)" }, + "developerOptionsStatus": { + "type": "boolean", + "description": "Developer options enabled or disabled on device (Read-only)" + }, "deviceCompromisedStatus": { "type": "string", "description": "Mobile Device compromised status (Read-only)" @@ -732,6 +740,13 @@ "type": "string", "description": "Name of the mobile operating system" }, + "otherAccountsInfo": { + "type": "array", + "description": "List of accounts added on device (Read-only)", + "items": { + "type": "string" + } + }, "resourceId": { "type": "string", "description": "Unique identifier of Mobile Device (Read-only)" @@ -744,10 +759,18 @@ "type": "string", "description": "Status of the device (Read-only)" }, + "supportsWorkProfile": { + "type": "boolean", + "description": "Work profile supported on device (Read-only)" + }, "type": { "type": "string", "description": "The type of device (Read-only)" }, + "unknownSourcesStatus": { + "type": "boolean", + "description": "Unknown sources enabled or disabled on device (Read-only)" + }, "userAgent": { "type": "string", "description": "Mobile Device user agent"
diff --git a/admin/directory_v1/admin-gen.go b/admin/directory/v1/admin-gen.go similarity index 99% rename from admin/directory_v1/admin-gen.go rename to admin/directory/v1/admin-gen.go index ca6e74a..9d9fae3 100644 --- a/admin/directory_v1/admin-gen.go +++ b/admin/directory/v1/admin-gen.go
@@ -4,7 +4,7 @@ // // Usage example: // -// import "google.golang.org/api/admin/directory_v1" +// import "google.golang.org/api/admin/directory/v1" // ... // adminService, err := admin.New(oauthHttpClient) package admin @@ -627,6 +627,10 @@ // MobileDevice: JSON template for Mobile Device resource in Directory // API. type MobileDevice struct { + // AdbStatus: Adb (USB debugging) enabled or disabled on device + // (Read-only) + AdbStatus bool `json:"adbStatus,omitempty"` + // Applications: List of applications installed on Mobile Device Applications []*MobileDeviceApplications `json:"applications,omitempty"` @@ -640,6 +644,10 @@ // (Read-only) DefaultLanguage string `json:"defaultLanguage,omitempty"` + // DeveloperOptionsStatus: Developer options enabled or disabled on + // device (Read-only) + DeveloperOptionsStatus bool `json:"developerOptionsStatus,omitempty"` + // DeviceCompromisedStatus: Mobile Device compromised status (Read-only) DeviceCompromisedStatus string `json:"deviceCompromisedStatus,omitempty"` @@ -694,6 +702,9 @@ // Os: Name of the mobile operating system Os string `json:"os,omitempty"` + // OtherAccountsInfo: List of accounts added on device (Read-only) + OtherAccountsInfo []string `json:"otherAccountsInfo,omitempty"` + // ResourceId: Unique identifier of Mobile Device (Read-only) ResourceId string `json:"resourceId,omitempty"` @@ -703,9 +714,16 @@ // Status: Status of the device (Read-only) Status string `json:"status,omitempty"` + // SupportsWorkProfile: Work profile supported on device (Read-only) + SupportsWorkProfile bool `json:"supportsWorkProfile,omitempty"` + // Type: The type of device (Read-only) Type string `json:"type,omitempty"` + // UnknownSourcesStatus: Unknown sources enabled or disabled on device + // (Read-only) + UnknownSourcesStatus bool `json:"unknownSourcesStatus,omitempty"` + // UserAgent: Mobile Device user agent UserAgent string `json:"userAgent,omitempty"`
diff --git a/admin/email_migration_v2/admin-api.json b/admin/email_migration/v2/admin-api.json similarity index 97% rename from admin/email_migration_v2/admin-api.json rename to admin/email_migration/v2/admin-api.json index 209ab8f..a52012c 100644 --- a/admin/email_migration_v2/admin-api.json +++ b/admin/email_migration/v2/admin-api.json
@@ -1,11 +1,11 @@ { "kind": "discovery#restDescription", - "etag": "\"uUWyYHXmEn-ab7WLvo8qNz2S8ws/Dam2iHq0kOgu8qnsdYB9fhgy5SY\"", + "etag": "\"ye6orv2F-1npMW3u9suM3a7C5Bo/_VRzIG5q4_x1FzCCxocLHIuiUhw\"", "discoveryVersion": "v1", "id": "admin:email_migration_v2", "name": "admin", "version": "email_migration_v2", - "revision": "20140903", + "revision": "20150303", "title": "Email Migration API v2", "description": "Email Migration API lets you migrate emails of users to Google backends.", "ownerDomain": "google.com",
diff --git a/admin/email_migration_v2/admin-gen.go b/admin/email_migration/v2/admin-gen.go similarity index 98% rename from admin/email_migration_v2/admin-gen.go rename to admin/email_migration/v2/admin-gen.go index dc3299b..d7162dc 100644 --- a/admin/email_migration_v2/admin-gen.go +++ b/admin/email_migration/v2/admin-gen.go
@@ -4,7 +4,7 @@ // // Usage example: // -// import "google.golang.org/api/admin/email_migration_v2" +// import "google.golang.org/api/admin/email_migration/v2" // ... // adminService, err := admin.New(oauthHttpClient) package admin
diff --git a/admin/reports_v1/admin-api.json b/admin/reports/v1/admin-api.json similarity index 100% rename from admin/reports_v1/admin-api.json rename to admin/reports/v1/admin-api.json
diff --git a/admin/reports_v1/admin-gen.go b/admin/reports/v1/admin-gen.go similarity index 99% rename from admin/reports_v1/admin-gen.go rename to admin/reports/v1/admin-gen.go index 225721d..abb75f5 100644 --- a/admin/reports_v1/admin-gen.go +++ b/admin/reports/v1/admin-gen.go
@@ -4,7 +4,7 @@ // // Usage example: // -// import "google.golang.org/api/admin/reports_v1" +// import "google.golang.org/api/admin/reports/v1" // ... // adminService, err := admin.New(oauthHttpClient) package admin
diff --git a/google-api-go-generator/gen.go b/google-api-go-generator/gen.go index 9117954..10f466f 100644 --- a/google-api-go-generator/gen.go +++ b/google-api-go-generator/gen.go
@@ -287,6 +287,9 @@ m map[string]bool // lazily initialized } +// oddVersionRE matches unusual API names like directory_v1. +var oddVersionRE = regexp.MustCompile(`^(.+)_(v[\d\.]+)$`) + // renameVersion conditionally rewrites the provided version such // that the final path component of the import path doesn't look // like a Go identifier. This keeps the consistency that import paths @@ -295,12 +298,13 @@ // and have package NAME. // See https://github.com/google/google-api-go-client/issues/78 func renameVersion(version string) string { - // TODO: Add support for mapping hierarchical APIs (see bug for details). if version == "alpha" || version == "beta" { return "v0." + version - } else { - return version } + if m := oddVersionRE.FindStringSubmatch(version); m != nil { + return m[1] + "/" + m[2] + } + return version } func (p *namePool) Get(preferred string) string {
diff --git a/google-api-go-generator/gen_test.go b/google-api-go-generator/gen_test.go index 315548c..c70984d 100644 --- a/google-api-go-generator/gen_test.go +++ b/google-api-go-generator/gen_test.go
@@ -149,3 +149,27 @@ } } } + +func TestRenameVersion(t *testing.T) { + tests := []struct { + version, want string + }{ + { + version: "directory_v1", + want: "directory/v1", + }, + { + version: "email_migration_v1", + want: "email_migration/v1", + }, + { + version: "my_api_v1.2", + want: "my_api/v1.2", + }, + } + for _, test := range tests { + if got := renameVersion(test.version); got != test.want { + t.Errorf("renameVersion(%q) = %q; want %q", test.version, got, test.want) + } + } +}