Skip to content

Commit

Permalink
[public-api] only allow optional in update
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Nov 8, 2023
1 parent 9f692bb commit 37e26af
Show file tree
Hide file tree
Showing 9 changed files with 522 additions and 486 deletions.
4 changes: 4 additions & 0 deletions components/gitpod-protocol/src/public-api-converter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ describe("PublicAPIConverter", () => {
},
additionalEnvironmentVariables: [],
region: "dev",
prebuildId: "",
workspaceClass: "g1-standard",
editor: {
name: "code",
Expand Down Expand Up @@ -357,6 +358,7 @@ describe("PublicAPIConverter", () => {
},
additionalEnvironmentVariables: [],
region: "dev",
prebuildId: "",
workspaceClass: "g1-standard",
editor: {
name: "code",
Expand Down Expand Up @@ -497,6 +499,7 @@ describe("PublicAPIConverter", () => {
},
additionalEnvironmentVariables: [],
region: "dev",
prebuildId: "",
workspaceClass: "g1-standard",
editor: {
name: "code",
Expand Down Expand Up @@ -612,6 +615,7 @@ describe("PublicAPIConverter", () => {
},
additionalEnvironmentVariables: [],
region: "dev",
prebuildId: "",
workspaceClass: "g1-standard",
editor: {
name: "code",
Expand Down
42 changes: 23 additions & 19 deletions components/gitpod-protocol/src/public-api-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,27 @@ export class PublicAPIConverter {
phase.lastTransitionTime = Timestamp.fromDate(new Date(lastTransitionTime));

status.instanceId = arg.id;
status.message = arg.status.message;
if (arg.status.message) {
status.message = arg.status.message;
}
status.workspaceUrl = arg.ideUrl;
status.ports = this.toPorts(arg.status.exposedPorts);
status.conditions = this.toWorkspaceConditions(arg.status.conditions);
status.gitStatus = this.toGitStatus(arg, status.gitStatus);
workspace.region = arg.region;
workspace.workspaceClass = arg.workspaceClass;
if (arg.workspaceClass) {
workspace.workspaceClass = arg.workspaceClass;
}
workspace.editor = this.toEditor(arg.configuration.ideConfig);

return workspace;
}

toWorkspaceConditions(conditions: WorkspaceInstanceConditions): WorkspaceConditions {
const result = new WorkspaceConditions();
result.failed = conditions.failed;
result.timeout = conditions.timeout;
return result;
return new WorkspaceConditions({
failed: conditions.failed,
timeout: conditions.timeout,
});
}

toEditor(ideConfig: ConfigurationIdeConfig | undefined): EditorReference | undefined {
Expand Down Expand Up @@ -337,15 +341,15 @@ export class PublicAPIConverter {
}

toOrganizationMember(member: OrgMemberInfo): OrganizationMember {
const result = new OrganizationMember();
result.userId = member.userId;
result.fullName = member.fullName;
result.email = member.primaryEmail;
result.avatarUrl = member.avatarUrl;
result.role = this.toOrgMemberRole(member.role);
result.memberSince = Timestamp.fromDate(new Date(member.memberSince));
result.ownedByOrganization = member.ownedByOrganization;
return result;
return new OrganizationMember({
userId: member.userId,
fullName: member.fullName,
email: member.primaryEmail,
avatarUrl: member.avatarUrl,
role: this.toOrgMemberRole(member.role),
memberSince: Timestamp.fromDate(new Date(member.memberSince)),
ownedByOrganization: member.ownedByOrganization,
});
}

toOrgMemberRole(role: OrgMemberRole): OrganizationRole {
Expand All @@ -371,9 +375,9 @@ export class PublicAPIConverter {
}

toOrganizationSettings(settings: OrganizationSettingsProtocol): OrganizationSettings {
const result = new OrganizationSettings();
result.workspaceSharingDisabled = !!settings.workspaceSharingDisabled;
result.defaultWorkspaceImage = settings.defaultWorkspaceImage || undefined;
return result;
return new OrganizationSettings({
workspaceSharingDisabled: !!settings.workspaceSharingDisabled,
defaultWorkspaceImage: settings.defaultWorkspaceImage || undefined,
});
}
}
2 changes: 2 additions & 0 deletions components/public-api/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ breaking:
ignore:
# Do not enforce breaking change detection for the experimental package
- gitpod/experimental
# TODO enable again after landing style changes
- gitpod/v1
lint:
use:
- DEFAULT
Expand Down
16 changes: 10 additions & 6 deletions components/public-api/gitpod/v1/organization.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";

package gitpod.v1;

import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "gitpod/v1/pagination.proto";

Expand All @@ -18,9 +19,9 @@ message OrganizationMember {
string user_id = 1;
OrganizationRole role = 2;
google.protobuf.Timestamp member_since = 3;
optional string avatar_url = 4;
optional string full_name = 5;
optional string email = 6;
string avatar_url = 4;
string full_name = 5;
string email = 6;
bool owned_by_organization = 7;
}

Expand All @@ -32,7 +33,7 @@ enum OrganizationRole {

message OrganizationSettings {
bool workspace_sharing_disabled = 1;
optional string default_workspace_image = 2;
string default_workspace_image = 2;
}

service OrganizationService {
Expand Down Expand Up @@ -107,8 +108,11 @@ message UpdateOrganizationSettingsRequest {
// organization_id is the ID of the organization to update the settings for.
string organization_id = 1;

// settings are the settings to update
OrganizationSettings settings = 2;
google.protobuf.FieldMask reset_mask = 2;

optional bool workspace_sharing_disabled = 3;

optional string default_workspace_image = 4;
}

message UpdateOrganizationSettingsResponse {
Expand Down
16 changes: 8 additions & 8 deletions components/public-api/gitpod/v1/workspace.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ message Workspace {
// Obtain available regions using the ListRegions operation.
//
// +optional defaults to the user's default region
optional string region = 8;
string region = 8;

// workspace_class specifies the workspace class with which to create the
// workspace. Obtain available workspace classes using the ListWorkspaceClass
// operation.
//
// +optional defaults to the class configured on the project or the cluster's
// default class.
optional string workspace_class = 9;
string workspace_class = 9;

// editor specifies the editor that will be used with this workspace.
// Obtain available editors using the EditorService.ListEditors operation.
//
// +optional defaults to the default editor of the user
optional EditorReference editor = 10;
EditorReference editor = 10;

// context_url is the normalized URL from which the workspace was created
// TODO(ak) replace with resolveContextURL API
Expand All @@ -66,7 +66,7 @@ message Workspace {
// Prebuild ID is the unique identifier of the prebuild
// from which this workspace was created
// +optional if empty then this workspace was not created from a prebuild
optional string prebuild_id = 12;
string prebuild_id = 12;
}

message WorkspaceStatus {
Expand All @@ -77,7 +77,7 @@ message WorkspaceStatus {
WorkspacePhase phase = 1;

// message is an optional human-readable message detailing the current phase
optional string message = 2;
string message = 2;

// workspace_url is the URL of the workspace. Only present when the phase is
// running.
Expand All @@ -104,11 +104,11 @@ message WorkspaceStatus {
message WorkspaceConditions {
// failed contains technical details for the failure of the workspace.
// +optional If this field is empty, the workspace has not failed.
optional string failed = 1;
string failed = 1;

// timeout contains the reason the workspace has timed out.
// +optional If this field is empty, the workspace has not timed out.
optional string timeout = 2;
string timeout = 2;
}

// Admission level describes who can access a workspace instance and its ports.
Expand Down Expand Up @@ -256,5 +256,5 @@ message EditorReference {

message WorkspaceEnvironmentVariable {
string name = 1;
optional string value = 2;
string value = 2;
}
Loading

0 comments on commit 37e26af

Please sign in to comment.