diff --git a/api/internal/genapi/parse.go b/api/internal/genapi/parse.go index 740ff7a55..6eec971da 100644 --- a/api/internal/genapi/parse.go +++ b/api/internal/genapi/parse.go @@ -84,6 +84,7 @@ func packageFromFullName(fullName protoreflect.FullName) string { var ( stringValueName = (&wrapperspb.StringValue{}).ProtoReflect().Descriptor().FullName() boolValueName = (&wrapperspb.BoolValue{}).ProtoReflect().Descriptor().FullName() + uInt32ValueName = (&wrapperspb.UInt32Value{}).ProtoReflect().Descriptor().FullName() structValueName = (&_struct.Struct{}).ProtoReflect().Descriptor().FullName() timestampName = (×tamppb.Timestamp{}).ProtoReflect().Descriptor().FullName() ) @@ -94,6 +95,8 @@ func messageKind(fd protoreflect.FieldDescriptor) (ptr, pkg, name string) { return "", "", "string" case boolValueName: return "", "", "bool" + case uInt32ValueName: + return "", "", "uint32" case structValueName: return "", "", "map[string]interface{}" case timestampName: diff --git a/internal/gen/controller.swagger.json b/internal/gen/controller.swagger.json index fe19695fe..40e2b8409 100644 --- a/internal/gen/controller.swagger.json +++ b/internal/gen/controller.swagger.json @@ -2312,6 +2312,257 @@ "controller.api.services.v1.ScopeService" ] } + }, + "/v1/targets": { + "get": { + "summary": "Lists all Targets", + "operationId": "TargetService_ListTargets", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/controller.api.services.v1.ListTargetsResponse" + } + } + }, + "parameters": [ + { + "name": "scope_id", + "in": "query", + "required": false, + "type": "string" + }, + { + "name": "view", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + }, + "post": { + "summary": "Creates a single Target", + "operationId": "TargetService_CreateTarget", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + } + }, + "/v1/targets/{id}": { + "get": { + "summary": "Gets a single Target", + "operationId": "TargetService_GetTarget", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "view", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + }, + "delete": { + "summary": "Deletes a Target", + "operationId": "TargetService_DeleteTarget", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/controller.api.services.v1.DeleteTargetResponse" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + }, + "patch": { + "summary": "Updates a Target", + "operationId": "TargetService_UpdateTarget", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + }, + { + "name": "update_mask", + "in": "query", + "required": false, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi" + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + } + }, + "/v1/targets/{id}:add-host-sets": { + "post": { + "summary": "Adds existing Host Sets to a Target.", + "operationId": "TargetService_AddTargetHostSets", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/controller.api.services.v1.AddTargetHostSetsRequest" + } + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + } + }, + "/v1/targets/{id}:remove-host-sets": { + "post": { + "summary": "Removes Host Sets from the Target.", + "operationId": "TargetService_RemoveTargetHostSets", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, + "parameters": [ + { + "name": "id", + "description": "This host set's id.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/controller.api.services.v1.RemoveTargetHostSetsRequest" + } + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + } + }, + "/v1/targets/{id}:set-host-sets": { + "post": { + "summary": "Sets the Host Sets on the Target.", + "operationId": "TargetService_SetTargetHostSets", + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/controller.api.services.v1.SetTargetHostSetsRequest" + } + } + ], + "tags": [ + "controller.api.services.v1.TargetService" + ] + } } }, "definitions": { @@ -2928,6 +3179,85 @@ } } }, + "controller.api.resources.targets.v1.HostSet": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "host_catalog_id": { + "type": "string" + } + } + }, + "controller.api.resources.targets.v1.Target": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the resource\nOutput only.", + "readOnly": true + }, + "scope_id": { + "type": "string", + "description": "The id of the parent of this resource. This must be defined for creation of this resource, but is otherwise\nread only." + }, + "scope": { + "$ref": "#/definitions/controller.api.resources.scopes.v1.ScopeInfo", + "description": "Scope information for this resource\nOutput only.", + "readOnly": true + }, + "name": { + "type": "string", + "title": "Required name for identification purposes" + }, + "description": { + "type": "string", + "title": "Optional user-set description for identification purposes" + }, + "created_time": { + "type": "string", + "format": "date-time", + "description": "The time this resource was created\nOutput only.", + "readOnly": true + }, + "updated_time": { + "type": "string", + "format": "date-time", + "description": "The time this resource was last updated.\nOutput only.", + "readOnly": true + }, + "version": { + "type": "integer", + "format": "int64", + "description": "The version can be used in subsequent write requests to ensure this\nresource has not changed and to fail the write if it has." + }, + "type": { + "type": "string" + }, + "host_set_ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The ids of the host sets that make up this target." + }, + "host_sets": { + "type": "array", + "items": { + "$ref": "#/definitions/controller.api.resources.targets.v1.HostSet" + }, + "description": "The host sets that make up this target.\nOutput only.", + "readOnly": true + }, + "default_port": { + "type": "integer", + "format": "int64", + "description": "The default port a target should use if present." + } + }, + "title": "Target contains all fields related to a Target resource" + }, "controller.api.resources.users.v1.User": { "type": "object", "properties": { @@ -2947,7 +3277,7 @@ }, "description": { "type": "string", - "title": "Optional user-set descripton for identification purposes" + "title": "Optional user-set description for identification purposes" }, "created_time": { "type": "string", @@ -3080,6 +3410,33 @@ } } }, + "controller.api.services.v1.AddTargetHostSetsRequest": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "version": { + "type": "integer", + "format": "int64" + }, + "host_set_ids": { + "type": "array", + "items": { + "type": "string" + }, + "title": "A list of host set IDs which will be added to this target. Each host set\nreferenced here must be a child of a host catalog in the same scope as this\ntarget" + } + } + }, + "controller.api.services.v1.AddTargetHostSetsResponse": { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, "controller.api.services.v1.AuthenticateRequest": { "type": "object", "properties": { @@ -3226,6 +3583,17 @@ } } }, + "controller.api.services.v1.CreateTargetResponse": { + "type": "object", + "properties": { + "uri": { + "type": "string" + }, + "item": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, "controller.api.services.v1.CreateUserResponse": { "type": "object", "properties": { @@ -3318,6 +3686,15 @@ } } }, + "controller.api.services.v1.DeleteTargetResponse": { + "type": "object", + "properties": { + "existed": { + "type": "boolean", + "format": "boolean" + } + } + }, "controller.api.services.v1.DeleteUserResponse": { "type": "object", "properties": { @@ -3399,6 +3776,14 @@ } } }, + "controller.api.services.v1.GetTargetResponse": { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, "controller.api.services.v1.GetUserResponse": { "type": "object", "properties": { @@ -3506,6 +3891,17 @@ } } }, + "controller.api.services.v1.ListTargetsResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + } + }, "controller.api.services.v1.ListUsersResponse": { "type": "object", "properties": { @@ -3629,6 +4025,34 @@ } } }, + "controller.api.services.v1.RemoveTargetHostSetsRequest": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "This host set's id." + }, + "version": { + "type": "integer", + "format": "int64" + }, + "host_set_ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of host set IDs which should not be in the target when this request\nreturns." + } + } + }, + "controller.api.services.v1.RemoveTargetHostSetsResponse": { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, "controller.api.services.v1.SetGroupMembersRequest": { "type": "object", "properties": { @@ -3766,6 +4190,33 @@ } } }, + "controller.api.services.v1.SetTargetHostSetsRequest": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "version": { + "type": "integer", + "format": "int64" + }, + "host_set_ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "A list of host set IDs which will be set on this target. Each host set\nreferenced here must be a child of a host catalog in the same scope as this\ntarget." + } + } + }, + "controller.api.services.v1.SetTargetHostSetsResponse": { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, "controller.api.services.v1.StatusResponse": { "type": "object", "properties": { @@ -3849,6 +4300,14 @@ } } }, + "controller.api.services.v1.UpdateTargetResponse": { + "type": "object", + "properties": { + "item": { + "$ref": "#/definitions/controller.api.resources.targets.v1.Target" + } + } + }, "controller.api.services.v1.UpdateUserResponse": { "type": "object", "properties": { diff --git a/internal/gen/controller/api/resources/targets/target.pb.go b/internal/gen/controller/api/resources/targets/target.pb.go new file mode 100644 index 000000000..66cde3476 --- /dev/null +++ b/internal/gen/controller/api/resources/targets/target.pb.go @@ -0,0 +1,402 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.4 +// source: controller/api/resources/targets/v1/target.proto + +package targets + +import ( + proto "github.com/golang/protobuf/proto" + _ "github.com/golang/protobuf/ptypes/struct" + timestamp "github.com/golang/protobuf/ptypes/timestamp" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + scopes "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes" + _ "github.com/hashicorp/boundary/internal/gen/controller/protooptions" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type HostSet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,10,opt,name=id,proto3" json:"id,omitempty"` + HostCatalogId string `protobuf:"bytes,20,opt,name=host_catalog_id,json=hostCatalogId,proto3" json:"host_catalog_id,omitempty"` +} + +func (x *HostSet) Reset() { + *x = HostSet{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_resources_targets_v1_target_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HostSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HostSet) ProtoMessage() {} + +func (x *HostSet) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_resources_targets_v1_target_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HostSet.ProtoReflect.Descriptor instead. +func (*HostSet) Descriptor() ([]byte, []int) { + return file_controller_api_resources_targets_v1_target_proto_rawDescGZIP(), []int{0} +} + +func (x *HostSet) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *HostSet) GetHostCatalogId() string { + if x != nil { + return x.HostCatalogId + } + return "" +} + +// Target contains all fields related to a Target resource +type Target struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The ID of the resource + // Output only. + Id string `protobuf:"bytes,10,opt,name=id,proto3" json:"id,omitempty"` + // The id of the parent of this resource. This must be defined for creation of this resource, but is otherwise + // read only. + ScopeId string `protobuf:"bytes,20,opt,name=scope_id,json=scopeId,proto3" json:"scope_id,omitempty"` + // Scope information for this resource + // Output only. + Scope *scopes.ScopeInfo `protobuf:"bytes,30,opt,name=scope,proto3" json:"scope,omitempty"` + // Required name for identification purposes + Name *wrappers.StringValue `protobuf:"bytes,40,opt,name=name,proto3" json:"name,omitempty"` + // Optional user-set description for identification purposes + Description *wrappers.StringValue `protobuf:"bytes,50,opt,name=description,proto3" json:"description,omitempty"` + // The time this resource was created + // Output only. + CreatedTime *timestamp.Timestamp `protobuf:"bytes,60,opt,name=created_time,proto3" json:"created_time,omitempty"` + // The time this resource was last updated. + // Output only. + UpdatedTime *timestamp.Timestamp `protobuf:"bytes,70,opt,name=updated_time,proto3" json:"updated_time,omitempty"` + // The version can be used in subsequent write requests to ensure this + // resource has not changed and to fail the write if it has. + Version uint32 `protobuf:"varint,80,opt,name=version,proto3" json:"version,omitempty"` + Type string `protobuf:"bytes,90,opt,name=type,proto3" json:"type,omitempty"` + // The ids of the host sets that make up this target. + HostSetIds []string `protobuf:"bytes,100,rep,name=host_set_ids,json=hostSetIds,proto3" json:"host_set_ids,omitempty"` + // The host sets that make up this target. + // Output only. + HostSets []*HostSet `protobuf:"bytes,110,rep,name=host_sets,json=hostSets,proto3" json:"host_sets,omitempty"` + // The default port a target should use if present. + DefaultPort *wrappers.UInt32Value `protobuf:"bytes,120,opt,name=default_port,json=defaultPort,proto3" json:"default_port,omitempty"` +} + +func (x *Target) Reset() { + *x = Target{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_resources_targets_v1_target_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Target) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Target) ProtoMessage() {} + +func (x *Target) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_resources_targets_v1_target_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Target.ProtoReflect.Descriptor instead. +func (*Target) Descriptor() ([]byte, []int) { + return file_controller_api_resources_targets_v1_target_proto_rawDescGZIP(), []int{1} +} + +func (x *Target) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Target) GetScopeId() string { + if x != nil { + return x.ScopeId + } + return "" +} + +func (x *Target) GetScope() *scopes.ScopeInfo { + if x != nil { + return x.Scope + } + return nil +} + +func (x *Target) GetName() *wrappers.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *Target) GetDescription() *wrappers.StringValue { + if x != nil { + return x.Description + } + return nil +} + +func (x *Target) GetCreatedTime() *timestamp.Timestamp { + if x != nil { + return x.CreatedTime + } + return nil +} + +func (x *Target) GetUpdatedTime() *timestamp.Timestamp { + if x != nil { + return x.UpdatedTime + } + return nil +} + +func (x *Target) GetVersion() uint32 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *Target) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Target) GetHostSetIds() []string { + if x != nil { + return x.HostSetIds + } + return nil +} + +func (x *Target) GetHostSets() []*HostSet { + if x != nil { + return x.HostSets + } + return nil +} + +func (x *Target) GetDefaultPort() *wrappers.UInt32Value { + if x != nil { + return x.DefaultPort + } + return nil +} + +var File_controller_api_resources_targets_v1_target_proto protoreflect.FileDescriptor + +var file_controller_api_resources_targets_v1_target_proto_rawDesc = []byte{ + 0x0a, 0x30, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x23, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, + 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x41, 0x0a, 0x07, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x26, 0x0a, + 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, + 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x68, 0x6f, 0x73, 0x74, 0x43, 0x61, 0x74, 0x61, + 0x6c, 0x6f, 0x67, 0x49, 0x64, 0x22, 0xa5, 0x05, 0x0a, 0x06, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x43, 0x0a, 0x05, 0x73, + 0x63, 0x6f, 0x70, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x53, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, + 0x12, 0x46, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x28, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x14, 0xa0, 0xda, + 0x29, 0x01, 0xc2, 0xdd, 0x29, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x62, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x22, 0xa0, 0xda, 0x29, + 0x01, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x0c, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3e, 0x0a, 0x0c, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x46, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x50, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x5a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x68, 0x6f, + 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x64, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0a, 0x68, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, 0x73, 0x12, 0x49, 0x0a, 0x09, + 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x6e, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x52, 0x08, 0x68, + 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x12, 0x64, 0x0a, 0x0c, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x78, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x23, 0xa0, 0xda, 0x29, + 0x01, 0xc2, 0xdd, 0x29, 0x1b, 0x0a, 0x0c, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x70, + 0x6f, 0x72, 0x74, 0x12, 0x0b, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, 0x74, + 0x52, 0x0b, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x55, 0x5a, + 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, + 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x3b, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_controller_api_resources_targets_v1_target_proto_rawDescOnce sync.Once + file_controller_api_resources_targets_v1_target_proto_rawDescData = file_controller_api_resources_targets_v1_target_proto_rawDesc +) + +func file_controller_api_resources_targets_v1_target_proto_rawDescGZIP() []byte { + file_controller_api_resources_targets_v1_target_proto_rawDescOnce.Do(func() { + file_controller_api_resources_targets_v1_target_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_api_resources_targets_v1_target_proto_rawDescData) + }) + return file_controller_api_resources_targets_v1_target_proto_rawDescData +} + +var file_controller_api_resources_targets_v1_target_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_controller_api_resources_targets_v1_target_proto_goTypes = []interface{}{ + (*HostSet)(nil), // 0: controller.api.resources.targets.v1.HostSet + (*Target)(nil), // 1: controller.api.resources.targets.v1.Target + (*scopes.ScopeInfo)(nil), // 2: controller.api.resources.scopes.v1.ScopeInfo + (*wrappers.StringValue)(nil), // 3: google.protobuf.StringValue + (*timestamp.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*wrappers.UInt32Value)(nil), // 5: google.protobuf.UInt32Value +} +var file_controller_api_resources_targets_v1_target_proto_depIdxs = []int32{ + 2, // 0: controller.api.resources.targets.v1.Target.scope:type_name -> controller.api.resources.scopes.v1.ScopeInfo + 3, // 1: controller.api.resources.targets.v1.Target.name:type_name -> google.protobuf.StringValue + 3, // 2: controller.api.resources.targets.v1.Target.description:type_name -> google.protobuf.StringValue + 4, // 3: controller.api.resources.targets.v1.Target.created_time:type_name -> google.protobuf.Timestamp + 4, // 4: controller.api.resources.targets.v1.Target.updated_time:type_name -> google.protobuf.Timestamp + 0, // 5: controller.api.resources.targets.v1.Target.host_sets:type_name -> controller.api.resources.targets.v1.HostSet + 5, // 6: controller.api.resources.targets.v1.Target.default_port:type_name -> google.protobuf.UInt32Value + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_controller_api_resources_targets_v1_target_proto_init() } +func file_controller_api_resources_targets_v1_target_proto_init() { + if File_controller_api_resources_targets_v1_target_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_controller_api_resources_targets_v1_target_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HostSet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_resources_targets_v1_target_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Target); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_controller_api_resources_targets_v1_target_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_controller_api_resources_targets_v1_target_proto_goTypes, + DependencyIndexes: file_controller_api_resources_targets_v1_target_proto_depIdxs, + MessageInfos: file_controller_api_resources_targets_v1_target_proto_msgTypes, + }.Build() + File_controller_api_resources_targets_v1_target_proto = out.File + file_controller_api_resources_targets_v1_target_proto_rawDesc = nil + file_controller_api_resources_targets_v1_target_proto_goTypes = nil + file_controller_api_resources_targets_v1_target_proto_depIdxs = nil +} diff --git a/internal/gen/controller/api/resources/users/user.pb.go b/internal/gen/controller/api/resources/users/user.pb.go index 45f98cc58..e7c64ad5b 100644 --- a/internal/gen/controller/api/resources/users/user.pb.go +++ b/internal/gen/controller/api/resources/users/user.pb.go @@ -43,7 +43,7 @@ type User struct { Scope *scopes.ScopeInfo `protobuf:"bytes,20,opt,name=scope,proto3" json:"scope,omitempty"` // Optional name for identification purposes Name *wrappers.StringValue `protobuf:"bytes,30,opt,name=name,proto3" json:"name,omitempty"` - // Optional user-set descripton for identification purposes + // Optional user-set description for identification purposes Description *wrappers.StringValue `protobuf:"bytes,40,opt,name=description,proto3" json:"description,omitempty"` // The time this resource was created // Output only. diff --git a/internal/gen/controller/api/services/target_service.pb.go b/internal/gen/controller/api/services/target_service.pb.go new file mode 100644 index 000000000..1ef09c589 --- /dev/null +++ b/internal/gen/controller/api/services/target_service.pb.go @@ -0,0 +1,1800 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.12.4 +// source: controller/api/services/v1/target_service.proto + +package services + +import ( + context "context" + proto "github.com/golang/protobuf/proto" + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + targets "github.com/hashicorp/boundary/internal/gen/controller/api/resources/targets" + _ "google.golang.org/genproto/googleapis/api/annotations" + field_mask "google.golang.org/genproto/protobuf/field_mask" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type GetTargetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + View string `protobuf:"bytes,2,opt,name=view,proto3" json:"view,omitempty"` +} + +func (x *GetTargetRequest) Reset() { + *x = GetTargetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetTargetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTargetRequest) ProtoMessage() {} + +func (x *GetTargetRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTargetRequest.ProtoReflect.Descriptor instead. +func (*GetTargetRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{0} +} + +func (x *GetTargetRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *GetTargetRequest) GetView() string { + if x != nil { + return x.View + } + return "" +} + +type GetTargetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *targets.Target `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *GetTargetResponse) Reset() { + *x = GetTargetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetTargetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTargetResponse) ProtoMessage() {} + +func (x *GetTargetResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTargetResponse.ProtoReflect.Descriptor instead. +func (*GetTargetResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{1} +} + +func (x *GetTargetResponse) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +type ListTargetsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ScopeId string `protobuf:"bytes,1,opt,name=scope_id,json=scopeId,proto3" json:"scope_id,omitempty"` + View string `protobuf:"bytes,2,opt,name=view,proto3" json:"view,omitempty"` +} + +func (x *ListTargetsRequest) Reset() { + *x = ListTargetsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTargetsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTargetsRequest) ProtoMessage() {} + +func (x *ListTargetsRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListTargetsRequest.ProtoReflect.Descriptor instead. +func (*ListTargetsRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{2} +} + +func (x *ListTargetsRequest) GetScopeId() string { + if x != nil { + return x.ScopeId + } + return "" +} + +func (x *ListTargetsRequest) GetView() string { + if x != nil { + return x.View + } + return "" +} + +type ListTargetsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*targets.Target `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *ListTargetsResponse) Reset() { + *x = ListTargetsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListTargetsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListTargetsResponse) ProtoMessage() {} + +func (x *ListTargetsResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListTargetsResponse.ProtoReflect.Descriptor instead. +func (*ListTargetsResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{3} +} + +func (x *ListTargetsResponse) GetItems() []*targets.Target { + if x != nil { + return x.Items + } + return nil +} + +type CreateTargetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *targets.Target `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *CreateTargetRequest) Reset() { + *x = CreateTargetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateTargetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTargetRequest) ProtoMessage() {} + +func (x *CreateTargetRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateTargetRequest.ProtoReflect.Descriptor instead. +func (*CreateTargetRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateTargetRequest) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +type CreateTargetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"` + Item *targets.Target `protobuf:"bytes,2,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *CreateTargetResponse) Reset() { + *x = CreateTargetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateTargetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTargetResponse) ProtoMessage() {} + +func (x *CreateTargetResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateTargetResponse.ProtoReflect.Descriptor instead. +func (*CreateTargetResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateTargetResponse) GetUri() string { + if x != nil { + return x.Uri + } + return "" +} + +func (x *CreateTargetResponse) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +type UpdateTargetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Item *targets.Target `protobuf:"bytes,2,opt,name=item,proto3" json:"item,omitempty"` + UpdateMask *field_mask.FieldMask `protobuf:"bytes,3,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` +} + +func (x *UpdateTargetRequest) Reset() { + *x = UpdateTargetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateTargetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateTargetRequest) ProtoMessage() {} + +func (x *UpdateTargetRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateTargetRequest.ProtoReflect.Descriptor instead. +func (*UpdateTargetRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateTargetRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *UpdateTargetRequest) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +func (x *UpdateTargetRequest) GetUpdateMask() *field_mask.FieldMask { + if x != nil { + return x.UpdateMask + } + return nil +} + +type UpdateTargetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *targets.Target `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *UpdateTargetResponse) Reset() { + *x = UpdateTargetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateTargetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateTargetResponse) ProtoMessage() {} + +func (x *UpdateTargetResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateTargetResponse.ProtoReflect.Descriptor instead. +func (*UpdateTargetResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateTargetResponse) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +type DeleteTargetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *DeleteTargetRequest) Reset() { + *x = DeleteTargetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteTargetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteTargetRequest) ProtoMessage() {} + +func (x *DeleteTargetRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteTargetRequest.ProtoReflect.Descriptor instead. +func (*DeleteTargetRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteTargetRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type DeleteTargetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Existed bool `protobuf:"varint,1,opt,name=existed,proto3" json:"existed,omitempty"` +} + +func (x *DeleteTargetResponse) Reset() { + *x = DeleteTargetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteTargetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteTargetResponse) ProtoMessage() {} + +func (x *DeleteTargetResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteTargetResponse.ProtoReflect.Descriptor instead. +func (*DeleteTargetResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteTargetResponse) GetExisted() bool { + if x != nil { + return x.Existed + } + return false +} + +type AddTargetHostSetsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` + // A list of host set IDs which will be added to this target. Each host set + // referenced here must be a child of a host catalog in the same scope as this + // target + HostSetIds []string `protobuf:"bytes,3,rep,name=host_set_ids,json=hostSetIds,proto3" json:"host_set_ids,omitempty"` +} + +func (x *AddTargetHostSetsRequest) Reset() { + *x = AddTargetHostSetsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddTargetHostSetsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddTargetHostSetsRequest) ProtoMessage() {} + +func (x *AddTargetHostSetsRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddTargetHostSetsRequest.ProtoReflect.Descriptor instead. +func (*AddTargetHostSetsRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{10} +} + +func (x *AddTargetHostSetsRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *AddTargetHostSetsRequest) GetVersion() uint32 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *AddTargetHostSetsRequest) GetHostSetIds() []string { + if x != nil { + return x.HostSetIds + } + return nil +} + +type AddTargetHostSetsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *targets.Target `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *AddTargetHostSetsResponse) Reset() { + *x = AddTargetHostSetsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddTargetHostSetsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddTargetHostSetsResponse) ProtoMessage() {} + +func (x *AddTargetHostSetsResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddTargetHostSetsResponse.ProtoReflect.Descriptor instead. +func (*AddTargetHostSetsResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{11} +} + +func (x *AddTargetHostSetsResponse) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +type SetTargetHostSetsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` + // A list of host set IDs which will be set on this target. Each host set + // referenced here must be a child of a host catalog in the same scope as this + // target. + HostSetIds []string `protobuf:"bytes,3,rep,name=host_set_ids,json=hostSetIds,proto3" json:"host_set_ids,omitempty"` +} + +func (x *SetTargetHostSetsRequest) Reset() { + *x = SetTargetHostSetsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetTargetHostSetsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetTargetHostSetsRequest) ProtoMessage() {} + +func (x *SetTargetHostSetsRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetTargetHostSetsRequest.ProtoReflect.Descriptor instead. +func (*SetTargetHostSetsRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{12} +} + +func (x *SetTargetHostSetsRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SetTargetHostSetsRequest) GetVersion() uint32 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *SetTargetHostSetsRequest) GetHostSetIds() []string { + if x != nil { + return x.HostSetIds + } + return nil +} + +type SetTargetHostSetsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *targets.Target `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *SetTargetHostSetsResponse) Reset() { + *x = SetTargetHostSetsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetTargetHostSetsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetTargetHostSetsResponse) ProtoMessage() {} + +func (x *SetTargetHostSetsResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetTargetHostSetsResponse.ProtoReflect.Descriptor instead. +func (*SetTargetHostSetsResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{13} +} + +func (x *SetTargetHostSetsResponse) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +type RemoveTargetHostSetsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // This host set's id. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"` + // A list of host set IDs which should not be in the target when this request + // returns. + HostSetIds []string `protobuf:"bytes,3,rep,name=host_set_ids,json=hostSetIds,proto3" json:"host_set_ids,omitempty"` +} + +func (x *RemoveTargetHostSetsRequest) Reset() { + *x = RemoveTargetHostSetsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveTargetHostSetsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveTargetHostSetsRequest) ProtoMessage() {} + +func (x *RemoveTargetHostSetsRequest) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveTargetHostSetsRequest.ProtoReflect.Descriptor instead. +func (*RemoveTargetHostSetsRequest) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{14} +} + +func (x *RemoveTargetHostSetsRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *RemoveTargetHostSetsRequest) GetVersion() uint32 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *RemoveTargetHostSetsRequest) GetHostSetIds() []string { + if x != nil { + return x.HostSetIds + } + return nil +} + +type RemoveTargetHostSetsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item *targets.Target `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` +} + +func (x *RemoveTargetHostSetsResponse) Reset() { + *x = RemoveTargetHostSetsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveTargetHostSetsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveTargetHostSetsResponse) ProtoMessage() {} + +func (x *RemoveTargetHostSetsResponse) ProtoReflect() protoreflect.Message { + mi := &file_controller_api_services_v1_target_service_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveTargetHostSetsResponse.ProtoReflect.Descriptor instead. +func (*RemoveTargetHostSetsResponse) Descriptor() ([]byte, []int) { + return file_controller_api_services_v1_target_service_proto_rawDescGZIP(), []int{15} +} + +func (x *RemoveTargetHostSetsResponse) GetItem() *targets.Target { + if x != nil { + return x.Item + } + return nil +} + +var File_controller_api_services_v1_target_service_proto protoreflect.FileDescriptor + +var file_controller_api_services_v1_target_service_proto_rawDesc = []byte{ + 0x0a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x1a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x1a, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, + 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, + 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2f, + 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x36, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x76, 0x69, 0x65, 0x77, 0x22, 0x54, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x04, + 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x43, 0x0a, + 0x12, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x76, 0x69, 0x65, 0x77, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x76, 0x69, + 0x65, 0x77, 0x22, 0x58, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x05, 0x69, 0x74, 0x65, + 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x56, 0x0a, 0x13, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, + 0x69, 0x74, 0x65, 0x6d, 0x22, 0x69, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x75, 0x72, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x3f, + 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, + 0xa3, 0x01, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3f, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x57, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, + 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x25, + 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x30, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x65, 0x78, 0x69, 0x73, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x65, 0x78, 0x69, 0x73, 0x74, 0x65, 0x64, 0x22, 0x66, 0x0a, 0x18, 0x41, 0x64, 0x64, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, + 0x0c, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, 0x73, 0x22, + 0x5c, 0x0a, 0x19, 0x41, 0x64, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, + 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x04, + 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x66, 0x0a, + 0x18, 0x53, 0x65, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, + 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0c, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, + 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x6f, 0x73, 0x74, 0x53, + 0x65, 0x74, 0x49, 0x64, 0x73, 0x22, 0x5c, 0x0a, 0x19, 0x53, 0x65, 0x74, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, 0x69, + 0x74, 0x65, 0x6d, 0x22, 0x69, 0x0a, 0x1b, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0c, + 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0a, 0x68, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, 0x73, 0x22, 0x5f, + 0x0a, 0x1c, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, + 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, + 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x32, + 0xf0, 0x0b, 0x0a, 0x0d, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0xa1, 0x01, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, + 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x18, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x16, 0x12, + 0x14, 0x47, 0x65, 0x74, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x99, 0x01, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x73, 0x12, 0x2e, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, + 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x12, 0x0b, + 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x92, 0x41, 0x13, 0x12, 0x11, + 0x4c, 0x69, 0x73, 0x74, 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x73, 0x12, 0xae, 0x01, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x0b, 0x2f, + 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, + 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x19, 0x12, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x12, 0xac, 0x01, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, + 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x39, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x32, 0x10, + 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, + 0x3a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x12, 0x12, + 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x12, 0xa0, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x12, 0x2f, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x2a, 0x10, 0x2f, + 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x92, + 0x41, 0x12, 0x12, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x12, 0xda, 0x01, 0x0a, 0x11, 0x41, 0x64, 0x64, 0x54, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x12, 0x34, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x35, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x64, + 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x58, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x22, + 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, + 0x7d, 0x3a, 0x61, 0x64, 0x64, 0x2d, 0x68, 0x6f, 0x73, 0x74, 0x2d, 0x73, 0x65, 0x74, 0x73, 0x3a, + 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x26, 0x12, 0x24, 0x41, 0x64, 0x64, + 0x73, 0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x48, 0x6f, 0x73, 0x74, 0x20, + 0x53, 0x65, 0x74, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x2e, 0x12, 0xd7, 0x01, 0x0a, 0x11, 0x53, 0x65, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, + 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x12, 0x34, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, + 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x55, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x22, 0x1e, 0x2f, 0x76, + 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x3a, 0x73, + 0x65, 0x74, 0x2d, 0x68, 0x6f, 0x73, 0x74, 0x2d, 0x73, 0x65, 0x74, 0x73, 0x3a, 0x01, 0x2a, 0x62, + 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x23, 0x12, 0x21, 0x53, 0x65, 0x74, 0x73, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x48, 0x6f, 0x73, 0x74, 0x20, 0x53, 0x65, 0x74, 0x73, 0x20, 0x6f, 0x6e, 0x20, + 0x74, 0x68, 0x65, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2e, 0x12, 0xe4, 0x01, 0x0a, 0x14, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, + 0x53, 0x65, 0x74, 0x73, 0x12, 0x37, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, + 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, + 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x59, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x22, + 0x21, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, + 0x7d, 0x3a, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x2d, 0x68, 0x6f, 0x73, 0x74, 0x2d, 0x73, 0x65, + 0x74, 0x73, 0x3a, 0x01, 0x2a, 0x62, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x92, 0x41, 0x24, 0x12, 0x22, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x48, 0x6f, 0x73, 0x74, 0x20, 0x53, 0x65, 0x74, + 0x73, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x74, 0x68, 0x65, 0x20, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x2e, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, + 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_controller_api_services_v1_target_service_proto_rawDescOnce sync.Once + file_controller_api_services_v1_target_service_proto_rawDescData = file_controller_api_services_v1_target_service_proto_rawDesc +) + +func file_controller_api_services_v1_target_service_proto_rawDescGZIP() []byte { + file_controller_api_services_v1_target_service_proto_rawDescOnce.Do(func() { + file_controller_api_services_v1_target_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_api_services_v1_target_service_proto_rawDescData) + }) + return file_controller_api_services_v1_target_service_proto_rawDescData +} + +var file_controller_api_services_v1_target_service_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_controller_api_services_v1_target_service_proto_goTypes = []interface{}{ + (*GetTargetRequest)(nil), // 0: controller.api.services.v1.GetTargetRequest + (*GetTargetResponse)(nil), // 1: controller.api.services.v1.GetTargetResponse + (*ListTargetsRequest)(nil), // 2: controller.api.services.v1.ListTargetsRequest + (*ListTargetsResponse)(nil), // 3: controller.api.services.v1.ListTargetsResponse + (*CreateTargetRequest)(nil), // 4: controller.api.services.v1.CreateTargetRequest + (*CreateTargetResponse)(nil), // 5: controller.api.services.v1.CreateTargetResponse + (*UpdateTargetRequest)(nil), // 6: controller.api.services.v1.UpdateTargetRequest + (*UpdateTargetResponse)(nil), // 7: controller.api.services.v1.UpdateTargetResponse + (*DeleteTargetRequest)(nil), // 8: controller.api.services.v1.DeleteTargetRequest + (*DeleteTargetResponse)(nil), // 9: controller.api.services.v1.DeleteTargetResponse + (*AddTargetHostSetsRequest)(nil), // 10: controller.api.services.v1.AddTargetHostSetsRequest + (*AddTargetHostSetsResponse)(nil), // 11: controller.api.services.v1.AddTargetHostSetsResponse + (*SetTargetHostSetsRequest)(nil), // 12: controller.api.services.v1.SetTargetHostSetsRequest + (*SetTargetHostSetsResponse)(nil), // 13: controller.api.services.v1.SetTargetHostSetsResponse + (*RemoveTargetHostSetsRequest)(nil), // 14: controller.api.services.v1.RemoveTargetHostSetsRequest + (*RemoveTargetHostSetsResponse)(nil), // 15: controller.api.services.v1.RemoveTargetHostSetsResponse + (*targets.Target)(nil), // 16: controller.api.resources.targets.v1.Target + (*field_mask.FieldMask)(nil), // 17: google.protobuf.FieldMask +} +var file_controller_api_services_v1_target_service_proto_depIdxs = []int32{ + 16, // 0: controller.api.services.v1.GetTargetResponse.item:type_name -> controller.api.resources.targets.v1.Target + 16, // 1: controller.api.services.v1.ListTargetsResponse.items:type_name -> controller.api.resources.targets.v1.Target + 16, // 2: controller.api.services.v1.CreateTargetRequest.item:type_name -> controller.api.resources.targets.v1.Target + 16, // 3: controller.api.services.v1.CreateTargetResponse.item:type_name -> controller.api.resources.targets.v1.Target + 16, // 4: controller.api.services.v1.UpdateTargetRequest.item:type_name -> controller.api.resources.targets.v1.Target + 17, // 5: controller.api.services.v1.UpdateTargetRequest.update_mask:type_name -> google.protobuf.FieldMask + 16, // 6: controller.api.services.v1.UpdateTargetResponse.item:type_name -> controller.api.resources.targets.v1.Target + 16, // 7: controller.api.services.v1.AddTargetHostSetsResponse.item:type_name -> controller.api.resources.targets.v1.Target + 16, // 8: controller.api.services.v1.SetTargetHostSetsResponse.item:type_name -> controller.api.resources.targets.v1.Target + 16, // 9: controller.api.services.v1.RemoveTargetHostSetsResponse.item:type_name -> controller.api.resources.targets.v1.Target + 0, // 10: controller.api.services.v1.TargetService.GetTarget:input_type -> controller.api.services.v1.GetTargetRequest + 2, // 11: controller.api.services.v1.TargetService.ListTargets:input_type -> controller.api.services.v1.ListTargetsRequest + 4, // 12: controller.api.services.v1.TargetService.CreateTarget:input_type -> controller.api.services.v1.CreateTargetRequest + 6, // 13: controller.api.services.v1.TargetService.UpdateTarget:input_type -> controller.api.services.v1.UpdateTargetRequest + 8, // 14: controller.api.services.v1.TargetService.DeleteTarget:input_type -> controller.api.services.v1.DeleteTargetRequest + 10, // 15: controller.api.services.v1.TargetService.AddTargetHostSets:input_type -> controller.api.services.v1.AddTargetHostSetsRequest + 12, // 16: controller.api.services.v1.TargetService.SetTargetHostSets:input_type -> controller.api.services.v1.SetTargetHostSetsRequest + 14, // 17: controller.api.services.v1.TargetService.RemoveTargetHostSets:input_type -> controller.api.services.v1.RemoveTargetHostSetsRequest + 1, // 18: controller.api.services.v1.TargetService.GetTarget:output_type -> controller.api.services.v1.GetTargetResponse + 3, // 19: controller.api.services.v1.TargetService.ListTargets:output_type -> controller.api.services.v1.ListTargetsResponse + 5, // 20: controller.api.services.v1.TargetService.CreateTarget:output_type -> controller.api.services.v1.CreateTargetResponse + 7, // 21: controller.api.services.v1.TargetService.UpdateTarget:output_type -> controller.api.services.v1.UpdateTargetResponse + 9, // 22: controller.api.services.v1.TargetService.DeleteTarget:output_type -> controller.api.services.v1.DeleteTargetResponse + 11, // 23: controller.api.services.v1.TargetService.AddTargetHostSets:output_type -> controller.api.services.v1.AddTargetHostSetsResponse + 13, // 24: controller.api.services.v1.TargetService.SetTargetHostSets:output_type -> controller.api.services.v1.SetTargetHostSetsResponse + 15, // 25: controller.api.services.v1.TargetService.RemoveTargetHostSets:output_type -> controller.api.services.v1.RemoveTargetHostSetsResponse + 18, // [18:26] is the sub-list for method output_type + 10, // [10:18] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name +} + +func init() { file_controller_api_services_v1_target_service_proto_init() } +func file_controller_api_services_v1_target_service_proto_init() { + if File_controller_api_services_v1_target_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_controller_api_services_v1_target_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetTargetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetTargetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTargetsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListTargetsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateTargetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateTargetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateTargetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateTargetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteTargetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteTargetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddTargetHostSetsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddTargetHostSetsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SetTargetHostSetsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SetTargetHostSetsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveTargetHostSetsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controller_api_services_v1_target_service_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveTargetHostSetsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_controller_api_services_v1_target_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 16, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_controller_api_services_v1_target_service_proto_goTypes, + DependencyIndexes: file_controller_api_services_v1_target_service_proto_depIdxs, + MessageInfos: file_controller_api_services_v1_target_service_proto_msgTypes, + }.Build() + File_controller_api_services_v1_target_service_proto = out.File + file_controller_api_services_v1_target_service_proto_rawDesc = nil + file_controller_api_services_v1_target_service_proto_goTypes = nil + file_controller_api_services_v1_target_service_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// TargetServiceClient is the client API for TargetService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type TargetServiceClient interface { + // GetTarget returns a stored Target if present. The provided request + // must include the scope and target ID for the target being retrieved. If + // any of those IDs are missing, malformed or reference a non existing + // resource an error is returned. + GetTarget(ctx context.Context, in *GetTargetRequest, opts ...grpc.CallOption) (*GetTargetResponse, error) + // ListTargets returns a list of stored targets which exist inside the project + // referenced inside the request. The request must include the scope ID for + // the targets being retrieved. If the scope ID is missing, malformed, or + // reference a non existing scope, an error is returned. + ListTargets(ctx context.Context, in *ListTargetsRequest, opts ...grpc.CallOption) (*ListTargetsResponse, error) + // CreateTarget creates and stores a target in boundary. The provided + // request must include the scope id in which the target will be created. + // If the scope id is missing, malformed or references a non existing + // scope, an error is returned. If a name is provided that is in + // use in another target in the same scope, an error is returned. + CreateTarget(ctx context.Context, in *CreateTargetRequest, opts ...grpc.CallOption) (*CreateTargetResponse, error) + // UpdateTarget updates an existing target in boundary. The provided + // target must not have any read only fields set. The update mask must be + // included in the request and contain at least 1 mutable field. To unset + // a field's value, include the field in the update mask and don't set it + // in the provided target. An error is returned if either the scope + // or target ids are missing or reference a non existing resource. An error + // is also returned if the request attempts to update the name to one that is + // already in use in this scope. + UpdateTarget(ctx context.Context, in *UpdateTargetRequest, opts ...grpc.CallOption) (*UpdateTargetResponse, error) + // DeleteTarget removes a target from Boundary. If the provided scope or target ids + // are malformed or not provided an error is returned. No error is returned + // if either ids reference resources that do not exist as the response itself + // specifies if the resource existed before the DeleteTarget request was + // received. + DeleteTarget(ctx context.Context, in *DeleteTargetRequest, opts ...grpc.CallOption) (*DeleteTargetResponse, error) + // AddTargetHostSets adds host sets to this target. The provided request must + // include the scope ID and the target ID to which the host sets will be added. + // All host sets added to the provided target must be a child of a catalog that + // is a child of the same scope as this target. If the scope or target IDs are + // missing, malformed, or reference non-existing resources, an error is + // returned. + AddTargetHostSets(ctx context.Context, in *AddTargetHostSetsRequest, opts ...grpc.CallOption) (*AddTargetHostSetsResponse, error) + // SetTargetHostSets sets the target's host sets. Any existing host sets on the + // target are deleted if they are not included in this request. The + // provided request must include the scope, and the target ID on which the + // host sets will be set. All host sets in the request must be a child of + // a catalog that is in the same scope as the provided target. If any + // IDs are missing, malformed, or references a non-existing resource, an + // error is returned. + SetTargetHostSets(ctx context.Context, in *SetTargetHostSetsRequest, opts ...grpc.CallOption) (*SetTargetHostSetsResponse, error) + // RemoveTargetHostSets removes the host sets from the specified target. The + // provided request must include the scope and the target IDs for the target + // from which the host sets will be removed. If any of the IDs are missing, + // malformed, or references a non-existing scope or catalog, an error is + // returned. + RemoveTargetHostSets(ctx context.Context, in *RemoveTargetHostSetsRequest, opts ...grpc.CallOption) (*RemoveTargetHostSetsResponse, error) +} + +type targetServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTargetServiceClient(cc grpc.ClientConnInterface) TargetServiceClient { + return &targetServiceClient{cc} +} + +func (c *targetServiceClient) GetTarget(ctx context.Context, in *GetTargetRequest, opts ...grpc.CallOption) (*GetTargetResponse, error) { + out := new(GetTargetResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/GetTarget", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) ListTargets(ctx context.Context, in *ListTargetsRequest, opts ...grpc.CallOption) (*ListTargetsResponse, error) { + out := new(ListTargetsResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/ListTargets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) CreateTarget(ctx context.Context, in *CreateTargetRequest, opts ...grpc.CallOption) (*CreateTargetResponse, error) { + out := new(CreateTargetResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/CreateTarget", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) UpdateTarget(ctx context.Context, in *UpdateTargetRequest, opts ...grpc.CallOption) (*UpdateTargetResponse, error) { + out := new(UpdateTargetResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/UpdateTarget", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) DeleteTarget(ctx context.Context, in *DeleteTargetRequest, opts ...grpc.CallOption) (*DeleteTargetResponse, error) { + out := new(DeleteTargetResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/DeleteTarget", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) AddTargetHostSets(ctx context.Context, in *AddTargetHostSetsRequest, opts ...grpc.CallOption) (*AddTargetHostSetsResponse, error) { + out := new(AddTargetHostSetsResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/AddTargetHostSets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) SetTargetHostSets(ctx context.Context, in *SetTargetHostSetsRequest, opts ...grpc.CallOption) (*SetTargetHostSetsResponse, error) { + out := new(SetTargetHostSetsResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/SetTargetHostSets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *targetServiceClient) RemoveTargetHostSets(ctx context.Context, in *RemoveTargetHostSetsRequest, opts ...grpc.CallOption) (*RemoveTargetHostSetsResponse, error) { + out := new(RemoveTargetHostSetsResponse) + err := c.cc.Invoke(ctx, "/controller.api.services.v1.TargetService/RemoveTargetHostSets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TargetServiceServer is the server API for TargetService service. +type TargetServiceServer interface { + // GetTarget returns a stored Target if present. The provided request + // must include the scope and target ID for the target being retrieved. If + // any of those IDs are missing, malformed or reference a non existing + // resource an error is returned. + GetTarget(context.Context, *GetTargetRequest) (*GetTargetResponse, error) + // ListTargets returns a list of stored targets which exist inside the project + // referenced inside the request. The request must include the scope ID for + // the targets being retrieved. If the scope ID is missing, malformed, or + // reference a non existing scope, an error is returned. + ListTargets(context.Context, *ListTargetsRequest) (*ListTargetsResponse, error) + // CreateTarget creates and stores a target in boundary. The provided + // request must include the scope id in which the target will be created. + // If the scope id is missing, malformed or references a non existing + // scope, an error is returned. If a name is provided that is in + // use in another target in the same scope, an error is returned. + CreateTarget(context.Context, *CreateTargetRequest) (*CreateTargetResponse, error) + // UpdateTarget updates an existing target in boundary. The provided + // target must not have any read only fields set. The update mask must be + // included in the request and contain at least 1 mutable field. To unset + // a field's value, include the field in the update mask and don't set it + // in the provided target. An error is returned if either the scope + // or target ids are missing or reference a non existing resource. An error + // is also returned if the request attempts to update the name to one that is + // already in use in this scope. + UpdateTarget(context.Context, *UpdateTargetRequest) (*UpdateTargetResponse, error) + // DeleteTarget removes a target from Boundary. If the provided scope or target ids + // are malformed or not provided an error is returned. No error is returned + // if either ids reference resources that do not exist as the response itself + // specifies if the resource existed before the DeleteTarget request was + // received. + DeleteTarget(context.Context, *DeleteTargetRequest) (*DeleteTargetResponse, error) + // AddTargetHostSets adds host sets to this target. The provided request must + // include the scope ID and the target ID to which the host sets will be added. + // All host sets added to the provided target must be a child of a catalog that + // is a child of the same scope as this target. If the scope or target IDs are + // missing, malformed, or reference non-existing resources, an error is + // returned. + AddTargetHostSets(context.Context, *AddTargetHostSetsRequest) (*AddTargetHostSetsResponse, error) + // SetTargetHostSets sets the target's host sets. Any existing host sets on the + // target are deleted if they are not included in this request. The + // provided request must include the scope, and the target ID on which the + // host sets will be set. All host sets in the request must be a child of + // a catalog that is in the same scope as the provided target. If any + // IDs are missing, malformed, or references a non-existing resource, an + // error is returned. + SetTargetHostSets(context.Context, *SetTargetHostSetsRequest) (*SetTargetHostSetsResponse, error) + // RemoveTargetHostSets removes the host sets from the specified target. The + // provided request must include the scope and the target IDs for the target + // from which the host sets will be removed. If any of the IDs are missing, + // malformed, or references a non-existing scope or catalog, an error is + // returned. + RemoveTargetHostSets(context.Context, *RemoveTargetHostSetsRequest) (*RemoveTargetHostSetsResponse, error) +} + +// UnimplementedTargetServiceServer can be embedded to have forward compatible implementations. +type UnimplementedTargetServiceServer struct { +} + +func (*UnimplementedTargetServiceServer) GetTarget(context.Context, *GetTargetRequest) (*GetTargetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTarget not implemented") +} +func (*UnimplementedTargetServiceServer) ListTargets(context.Context, *ListTargetsRequest) (*ListTargetsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListTargets not implemented") +} +func (*UnimplementedTargetServiceServer) CreateTarget(context.Context, *CreateTargetRequest) (*CreateTargetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateTarget not implemented") +} +func (*UnimplementedTargetServiceServer) UpdateTarget(context.Context, *UpdateTargetRequest) (*UpdateTargetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateTarget not implemented") +} +func (*UnimplementedTargetServiceServer) DeleteTarget(context.Context, *DeleteTargetRequest) (*DeleteTargetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteTarget not implemented") +} +func (*UnimplementedTargetServiceServer) AddTargetHostSets(context.Context, *AddTargetHostSetsRequest) (*AddTargetHostSetsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddTargetHostSets not implemented") +} +func (*UnimplementedTargetServiceServer) SetTargetHostSets(context.Context, *SetTargetHostSetsRequest) (*SetTargetHostSetsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetTargetHostSets not implemented") +} +func (*UnimplementedTargetServiceServer) RemoveTargetHostSets(context.Context, *RemoveTargetHostSetsRequest) (*RemoveTargetHostSetsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveTargetHostSets not implemented") +} + +func RegisterTargetServiceServer(s *grpc.Server, srv TargetServiceServer) { + s.RegisterService(&_TargetService_serviceDesc, srv) +} + +func _TargetService_GetTarget_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTargetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).GetTarget(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/GetTarget", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).GetTarget(ctx, req.(*GetTargetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_ListTargets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListTargetsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).ListTargets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/ListTargets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).ListTargets(ctx, req.(*ListTargetsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_CreateTarget_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTargetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).CreateTarget(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/CreateTarget", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).CreateTarget(ctx, req.(*CreateTargetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_UpdateTarget_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateTargetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).UpdateTarget(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/UpdateTarget", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).UpdateTarget(ctx, req.(*UpdateTargetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_DeleteTarget_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteTargetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).DeleteTarget(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/DeleteTarget", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).DeleteTarget(ctx, req.(*DeleteTargetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_AddTargetHostSets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddTargetHostSetsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).AddTargetHostSets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/AddTargetHostSets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).AddTargetHostSets(ctx, req.(*AddTargetHostSetsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_SetTargetHostSets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetTargetHostSetsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).SetTargetHostSets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/SetTargetHostSets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).SetTargetHostSets(ctx, req.(*SetTargetHostSetsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TargetService_RemoveTargetHostSets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RemoveTargetHostSetsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TargetServiceServer).RemoveTargetHostSets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/controller.api.services.v1.TargetService/RemoveTargetHostSets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TargetServiceServer).RemoveTargetHostSets(ctx, req.(*RemoveTargetHostSetsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _TargetService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "controller.api.services.v1.TargetService", + HandlerType: (*TargetServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetTarget", + Handler: _TargetService_GetTarget_Handler, + }, + { + MethodName: "ListTargets", + Handler: _TargetService_ListTargets_Handler, + }, + { + MethodName: "CreateTarget", + Handler: _TargetService_CreateTarget_Handler, + }, + { + MethodName: "UpdateTarget", + Handler: _TargetService_UpdateTarget_Handler, + }, + { + MethodName: "DeleteTarget", + Handler: _TargetService_DeleteTarget_Handler, + }, + { + MethodName: "AddTargetHostSets", + Handler: _TargetService_AddTargetHostSets_Handler, + }, + { + MethodName: "SetTargetHostSets", + Handler: _TargetService_SetTargetHostSets_Handler, + }, + { + MethodName: "RemoveTargetHostSets", + Handler: _TargetService_RemoveTargetHostSets_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "controller/api/services/v1/target_service.proto", +} diff --git a/internal/gen/controller/api/services/target_service.pb.gw.go b/internal/gen/controller/api/services/target_service.pb.gw.go new file mode 100644 index 000000000..5a877532f --- /dev/null +++ b/internal/gen/controller/api/services/target_service.pb.gw.go @@ -0,0 +1,986 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: controller/api/services/v1/target_service.proto + +/* +Package services is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package services + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray + +var ( + filter_TargetService_GetTarget_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_TargetService_GetTarget_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTargetRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TargetService_GetTarget_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetTarget(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_GetTarget_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTargetRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TargetService_GetTarget_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetTarget(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_TargetService_ListTargets_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_TargetService_ListTargets_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListTargetsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TargetService_ListTargets_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListTargets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_ListTargets_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListTargetsRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TargetService_ListTargets_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListTargets(ctx, &protoReq) + return msg, metadata, err + +} + +func request_TargetService_CreateTarget_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateTargetRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Item); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.CreateTarget(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_CreateTarget_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreateTargetRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Item); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.CreateTarget(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_TargetService_UpdateTarget_0 = &utilities.DoubleArray{Encoding: map[string]int{"item": 0, "id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_TargetService_UpdateTarget_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateTargetRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Item); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { + if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Item); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } else { + protoReq.UpdateMask = fieldMask + } + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TargetService_UpdateTarget_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UpdateTarget(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_UpdateTarget_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UpdateTargetRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Item); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { + if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Item); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } else { + protoReq.UpdateMask = fieldMask + } + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TargetService_UpdateTarget_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UpdateTarget(ctx, &protoReq) + return msg, metadata, err + +} + +func request_TargetService_DeleteTarget_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteTargetRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.DeleteTarget(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_DeleteTarget_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteTargetRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.DeleteTarget(ctx, &protoReq) + return msg, metadata, err + +} + +func request_TargetService_AddTargetHostSets_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AddTargetHostSetsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.AddTargetHostSets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_AddTargetHostSets_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AddTargetHostSetsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.AddTargetHostSets(ctx, &protoReq) + return msg, metadata, err + +} + +func request_TargetService_SetTargetHostSets_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SetTargetHostSetsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.SetTargetHostSets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_SetTargetHostSets_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SetTargetHostSetsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.SetTargetHostSets(ctx, &protoReq) + return msg, metadata, err + +} + +func request_TargetService_RemoveTargetHostSets_0(ctx context.Context, marshaler runtime.Marshaler, client TargetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RemoveTargetHostSetsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.RemoveTargetHostSets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_TargetService_RemoveTargetHostSets_0(ctx context.Context, marshaler runtime.Marshaler, server TargetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RemoveTargetHostSetsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.RemoveTargetHostSets(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterTargetServiceHandlerServer registers the http handlers for service TargetService to "mux". +// UnaryRPC :call TargetServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterTargetServiceHandlerFromEndpoint instead. +func RegisterTargetServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TargetServiceServer) error { + + mux.Handle("GET", pattern_TargetService_GetTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/GetTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_GetTarget_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_GetTarget_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_GetTarget_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_TargetService_ListTargets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/ListTargets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_ListTargets_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_ListTargets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_CreateTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/CreateTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_CreateTarget_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_CreateTarget_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_CreateTarget_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_TargetService_UpdateTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/UpdateTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_UpdateTarget_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_UpdateTarget_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_UpdateTarget_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_TargetService_DeleteTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/DeleteTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_DeleteTarget_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_DeleteTarget_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_AddTargetHostSets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/AddTargetHostSets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_AddTargetHostSets_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_AddTargetHostSets_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_AddTargetHostSets_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_SetTargetHostSets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/SetTargetHostSets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_SetTargetHostSets_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_SetTargetHostSets_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_SetTargetHostSets_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_RemoveTargetHostSets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/controller.api.services.v1.TargetService/RemoveTargetHostSets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_TargetService_RemoveTargetHostSets_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_RemoveTargetHostSets_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_RemoveTargetHostSets_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterTargetServiceHandlerFromEndpoint is same as RegisterTargetServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterTargetServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterTargetServiceHandler(ctx, mux, conn) +} + +// RegisterTargetServiceHandler registers the http handlers for service TargetService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterTargetServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterTargetServiceHandlerClient(ctx, mux, NewTargetServiceClient(conn)) +} + +// RegisterTargetServiceHandlerClient registers the http handlers for service TargetService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TargetServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TargetServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "TargetServiceClient" to call the correct interceptors. +func RegisterTargetServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TargetServiceClient) error { + + mux.Handle("GET", pattern_TargetService_GetTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/GetTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_GetTarget_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_GetTarget_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_GetTarget_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_TargetService_ListTargets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/ListTargets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_ListTargets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_ListTargets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_CreateTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/CreateTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_CreateTarget_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_CreateTarget_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_CreateTarget_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_TargetService_UpdateTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/UpdateTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_UpdateTarget_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_UpdateTarget_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_UpdateTarget_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_TargetService_DeleteTarget_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/DeleteTarget") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_DeleteTarget_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_DeleteTarget_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_AddTargetHostSets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/AddTargetHostSets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_AddTargetHostSets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_AddTargetHostSets_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_AddTargetHostSets_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_SetTargetHostSets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/SetTargetHostSets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_SetTargetHostSets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_SetTargetHostSets_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_SetTargetHostSets_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_TargetService_RemoveTargetHostSets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req, "/controller.api.services.v1.TargetService/RemoveTargetHostSets") + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_TargetService_RemoveTargetHostSets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_TargetService_RemoveTargetHostSets_0(ctx, mux, outboundMarshaler, w, req, response_TargetService_RemoveTargetHostSets_0{resp}, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +type response_TargetService_GetTarget_0 struct { + proto.Message +} + +func (m response_TargetService_GetTarget_0) XXX_ResponseBody() interface{} { + response := m.Message.(*GetTargetResponse) + return response.Item +} + +type response_TargetService_CreateTarget_0 struct { + proto.Message +} + +func (m response_TargetService_CreateTarget_0) XXX_ResponseBody() interface{} { + response := m.Message.(*CreateTargetResponse) + return response.Item +} + +type response_TargetService_UpdateTarget_0 struct { + proto.Message +} + +func (m response_TargetService_UpdateTarget_0) XXX_ResponseBody() interface{} { + response := m.Message.(*UpdateTargetResponse) + return response.Item +} + +type response_TargetService_AddTargetHostSets_0 struct { + proto.Message +} + +func (m response_TargetService_AddTargetHostSets_0) XXX_ResponseBody() interface{} { + response := m.Message.(*AddTargetHostSetsResponse) + return response.Item +} + +type response_TargetService_SetTargetHostSets_0 struct { + proto.Message +} + +func (m response_TargetService_SetTargetHostSets_0) XXX_ResponseBody() interface{} { + response := m.Message.(*SetTargetHostSetsResponse) + return response.Item +} + +type response_TargetService_RemoveTargetHostSets_0 struct { + proto.Message +} + +func (m response_TargetService_RemoveTargetHostSets_0) XXX_ResponseBody() interface{} { + response := m.Message.(*RemoveTargetHostSetsResponse) + return response.Item +} + +var ( + pattern_TargetService_GetTarget_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "targets", "id"}, "")) + + pattern_TargetService_ListTargets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "targets"}, "")) + + pattern_TargetService_CreateTarget_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "targets"}, "")) + + pattern_TargetService_UpdateTarget_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "targets", "id"}, "")) + + pattern_TargetService_DeleteTarget_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "targets", "id"}, "")) + + pattern_TargetService_AddTargetHostSets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "targets", "id"}, "add-host-sets")) + + pattern_TargetService_SetTargetHostSets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "targets", "id"}, "set-host-sets")) + + pattern_TargetService_RemoveTargetHostSets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "targets", "id"}, "remove-host-sets")) +) + +var ( + forward_TargetService_GetTarget_0 = runtime.ForwardResponseMessage + + forward_TargetService_ListTargets_0 = runtime.ForwardResponseMessage + + forward_TargetService_CreateTarget_0 = runtime.ForwardResponseMessage + + forward_TargetService_UpdateTarget_0 = runtime.ForwardResponseMessage + + forward_TargetService_DeleteTarget_0 = runtime.ForwardResponseMessage + + forward_TargetService_AddTargetHostSets_0 = runtime.ForwardResponseMessage + + forward_TargetService_SetTargetHostSets_0 = runtime.ForwardResponseMessage + + forward_TargetService_RemoveTargetHostSets_0 = runtime.ForwardResponseMessage +) diff --git a/internal/proto/local/controller/api/resources/targets/v1/target.proto b/internal/proto/local/controller/api/resources/targets/v1/target.proto new file mode 100644 index 000000000..a47458a54 --- /dev/null +++ b/internal/proto/local/controller/api/resources/targets/v1/target.proto @@ -0,0 +1,61 @@ +syntax = "proto3"; + +package controller.api.resources.targets.v1; + +option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/resources/targets;targets"; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; +import "google/protobuf/struct.proto"; +import "controller/api/resources/scopes/v1/scope.proto"; +import "controller/custom_options/v1/options.proto"; + +message HostSet{ + string id = 10; + string host_catalog_id = 20; +} + +// Target contains all fields related to a Target resource +message Target { + // The ID of the resource + // Output only. + string id = 10; + + // The id of the parent of this resource. This must be defined for creation of this resource, but is otherwise + // read only. + string scope_id = 20; + + // Scope information for this resource + // Output only. + resources.scopes.v1.ScopeInfo scope = 30; + + // Required name for identification purposes + google.protobuf.StringValue name = 40 [(custom_options.v1.generate_sdk_option) = true, (custom_options.v1.mask_mapping) = {this:"name" that: "name"}]; + + // Optional user-set description for identification purposes + google.protobuf.StringValue description = 50 [(custom_options.v1.generate_sdk_option) = true, (custom_options.v1.mask_mapping) = {this:"description" that: "description"}]; + + // The time this resource was created + // Output only. + google.protobuf.Timestamp created_time = 60 [json_name="created_time"]; + + // The time this resource was last updated. + // Output only. + google.protobuf.Timestamp updated_time = 70 [json_name="updated_time"]; + + // The version can be used in subsequent write requests to ensure this + // resource has not changed and to fail the write if it has. + uint32 version = 80; + + string type = 90; + + // The ids of the host sets that make up this target. + repeated string host_set_ids = 100; + + // The host sets that make up this target. + // Output only. + repeated HostSet host_sets = 110; + + // The default port a target should use if present. + google.protobuf.UInt32Value default_port = 120 [(custom_options.v1.generate_sdk_option) = true, (custom_options.v1.mask_mapping) = {this:"default_port" that: "DefaultPort"}]; +} diff --git a/internal/proto/local/controller/api/resources/users/v1/user.proto b/internal/proto/local/controller/api/resources/users/v1/user.proto index 508847bc4..e2c4ffc29 100644 --- a/internal/proto/local/controller/api/resources/users/v1/user.proto +++ b/internal/proto/local/controller/api/resources/users/v1/user.proto @@ -22,7 +22,7 @@ message User { // Optional name for identification purposes google.protobuf.StringValue name = 30 [(custom_options.v1.generate_sdk_option) = true, (custom_options.v1.mask_mapping) = {this:"name" that: "name"}]; - // Optional user-set descripton for identification purposes + // Optional user-set description for identification purposes google.protobuf.StringValue description = 40 [(custom_options.v1.generate_sdk_option) = true, (custom_options.v1.mask_mapping) = {this:"description" that: "description"}]; // The time this resource was created diff --git a/internal/proto/local/controller/api/services/v1/target_service.proto b/internal/proto/local/controller/api/services/v1/target_service.proto new file mode 100644 index 000000000..4b5c48335 --- /dev/null +++ b/internal/proto/local/controller/api/services/v1/target_service.proto @@ -0,0 +1,229 @@ +syntax = "proto3"; + +package controller.api.services.v1; + +option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/services;services"; + +import "protoc-gen-openapiv2/options/annotations.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/field_mask.proto"; +import "controller/api/resources/targets/v1/target.proto"; + +service TargetService { + + // GetTarget returns a stored Target if present. The provided request + // must include the scope and target ID for the target being retrieved. If + // any of those IDs are missing, malformed or reference a non existing + // resource an error is returned. + rpc GetTarget(GetTargetRequest) returns (GetTargetResponse) { + option (google.api.http) = { + get: "/v1/targets/{id}" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Gets a single Target" + }; + } + + // ListTargets returns a list of stored targets which exist inside the project + // referenced inside the request. The request must include the scope ID for + // the targets being retrieved. If the scope ID is missing, malformed, or + // reference a non existing scope, an error is returned. + rpc ListTargets(ListTargetsRequest) returns (ListTargetsResponse) { + option (google.api.http) = { + get: "/v1/targets" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Lists all Targets" + }; + } + + // CreateTarget creates and stores a target in boundary. The provided + // request must include the scope id in which the target will be created. + // If the scope id is missing, malformed or references a non existing + // scope, an error is returned. If a name is provided that is in + // use in another target in the same scope, an error is returned. + rpc CreateTarget(CreateTargetRequest) returns (CreateTargetResponse) { + option (google.api.http) = { + post: "/v1/targets" + body: "item" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Creates a single Target" + }; + } + + // UpdateTarget updates an existing target in boundary. The provided + // target must not have any read only fields set. The update mask must be + // included in the request and contain at least 1 mutable field. To unset + // a field's value, include the field in the update mask and don't set it + // in the provided target. An error is returned if either the scope + // or target ids are missing or reference a non existing resource. An error + // is also returned if the request attempts to update the name to one that is + // already in use in this scope. + rpc UpdateTarget(UpdateTargetRequest) returns (UpdateTargetResponse) { + option (google.api.http) = { + patch: "/v1/targets/{id}" + body: "item" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Updates a Target" + }; + } + + // DeleteTarget removes a target from Boundary. If the provided scope or target ids + // are malformed or not provided an error is returned. No error is returned + // if either ids reference resources that do not exist as the response itself + // specifies if the resource existed before the DeleteTarget request was + // received. + rpc DeleteTarget(DeleteTargetRequest) returns (DeleteTargetResponse) { + option (google.api.http) = { + delete: "/v1/targets/{id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Deletes a Target" + }; + } + + + // AddTargetHostSets adds host sets to this target. The provided request must + // include the scope ID and the target ID to which the host sets will be added. + // All host sets added to the provided target must be a child of a catalog that + // is a child of the same scope as this target. If the scope or target IDs are + // missing, malformed, or reference non-existing resources, an error is + // returned. + rpc AddTargetHostSets(AddTargetHostSetsRequest) returns (AddTargetHostSetsResponse) { + option (google.api.http) = { + post: "/v1/targets/{id}:add-host-sets" + body: "*" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Adds existing Host Sets to a Target." + }; + } + + // SetTargetHostSets sets the target's host sets. Any existing host sets on the + // target are deleted if they are not included in this request. The + // provided request must include the scope, and the target ID on which the + // host sets will be set. All host sets in the request must be a child of + // a catalog that is in the same scope as the provided target. If any + // IDs are missing, malformed, or references a non-existing resource, an + // error is returned. + rpc SetTargetHostSets(SetTargetHostSetsRequest) returns (SetTargetHostSetsResponse) { + option (google.api.http) = { + post: "/v1/targets/{id}:set-host-sets" + body: "*" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Sets the Host Sets on the Target." + }; + } + + // RemoveTargetHostSets removes the host sets from the specified target. The + // provided request must include the scope and the target IDs for the target + // from which the host sets will be removed. If any of the IDs are missing, + // malformed, or references a non-existing scope or catalog, an error is + // returned. + rpc RemoveTargetHostSets(RemoveTargetHostSetsRequest) returns (RemoveTargetHostSetsResponse) { + option (google.api.http) = { + post: "/v1/targets/{id}:remove-host-sets" + body: "*" + response_body: "item" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + summary: "Removes Host Sets from the Target." + }; + } + +} + +message GetTargetRequest { + string id = 1; + string view = 2; +} + +message GetTargetResponse { + resources.targets.v1.Target item = 1; +} + +message ListTargetsRequest { + string scope_id = 1; + string view = 2; +} + +message ListTargetsResponse { + repeated resources.targets.v1.Target items = 1; +} + +message CreateTargetRequest { + resources.targets.v1.Target item = 1; +} + +message CreateTargetResponse { + string uri = 1; + resources.targets.v1.Target item = 2; +} + +message UpdateTargetRequest { + string id = 1; + resources.targets.v1.Target item = 2; + google.protobuf.FieldMask update_mask = 3; +} + +message UpdateTargetResponse { + resources.targets.v1.Target item = 1; +} + +message DeleteTargetRequest { + string id = 1; +} + +message DeleteTargetResponse { + bool existed = 1; +} + +message AddTargetHostSetsRequest { + string id = 1; + uint32 version = 2; + + // A list of host set IDs which will be added to this target. Each host set + // referenced here must be a child of a host catalog in the same scope as this + // target + repeated string host_set_ids = 3; +} + +message AddTargetHostSetsResponse { + api.resources.targets.v1.Target item = 1; +} + +message SetTargetHostSetsRequest { + string id = 1; + uint32 version = 2; + + // A list of host set IDs which will be set on this target. Each host set + // referenced here must be a child of a host catalog in the same scope as this + // target. + repeated string host_set_ids = 3; +} + +message SetTargetHostSetsResponse { + api.resources.targets.v1.Target item = 1; +} + +message RemoveTargetHostSetsRequest { + // This host set's id. + string id = 1; + uint32 version = 2; + + // A list of host set IDs which should not be in the target when this request + // returns. + repeated string host_set_ids = 3; +} + +message RemoveTargetHostSetsResponse { + api.resources.targets.v1.Target item = 1; +} diff --git a/internal/proto/local/controller/storage/target/store/v1/target.proto b/internal/proto/local/controller/storage/target/store/v1/target.proto index 0aa9791ff..5a92be31e 100644 --- a/internal/proto/local/controller/storage/target/store/v1/target.proto +++ b/internal/proto/local/controller/storage/target/store/v1/target.proto @@ -19,15 +19,11 @@ message TargetView { // name is the optional friendly name used to // access the Target via an API // @inject_tag: `gorm:"default:null"` - string name = 30 - [(custom_options.v1.mask_mapping) = { this: "name" that: "name" }]; + string name = 30; // description of the Target // @inject_tag: `gorm:"default:null"` - string description = 40 [(custom_options.v1.mask_mapping) = { - this: "description" - that: "description" - }]; + string description = 40; // create_time from the RDBMS // @inject_tag: `gorm:"default:current_timestamp"` @@ -102,5 +98,8 @@ message TcpTarget { // default port of the TargetTcp // @inject_tag: `gorm:"default:null"` - uint32 default_port = 80; + uint32 default_port = 80 [(custom_options.v1.mask_mapping) = { + this: "DefaultPort" + that: "default_port" + }]; } \ No newline at end of file diff --git a/internal/servers/controller/common/common.go b/internal/servers/controller/common/common.go index 183d492a9..b715568cb 100644 --- a/internal/servers/controller/common/common.go +++ b/internal/servers/controller/common/common.go @@ -6,12 +6,14 @@ import ( "github.com/hashicorp/boundary/internal/host/static" "github.com/hashicorp/boundary/internal/iam" "github.com/hashicorp/boundary/internal/servers" + "github.com/hashicorp/boundary/internal/target" ) type ( - IamRepoFactory func() (*iam.Repository, error) - StaticRepoFactory func() (*static.Repository, error) AuthTokenRepoFactory func() (*authtoken.Repository, error) - ServersRepoFactory func() (*servers.Repository, error) + IamRepoFactory func() (*iam.Repository, error) PasswordAuthRepoFactory func() (*password.Repository, error) + ServersRepoFactory func() (*servers.Repository, error) + StaticRepoFactory func() (*static.Repository, error) + TargetRepoFactory func() (*target.Repository, error) ) diff --git a/internal/servers/controller/controller.go b/internal/servers/controller/controller.go index acf48f160..241fed8be 100644 --- a/internal/servers/controller/controller.go +++ b/internal/servers/controller/controller.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/servers" "github.com/hashicorp/boundary/internal/servers/controller/common" + "github.com/hashicorp/boundary/internal/target" "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/sdk/helper/base62" "github.com/hashicorp/vault/sdk/helper/mlock" @@ -36,11 +37,12 @@ type Controller struct { workerStatusUpdateTimes *sync.Map // Repo factory methods - IamRepoFn common.IamRepoFactory - StaticHostRepoFn common.StaticRepoFactory AuthTokenRepoFn common.AuthTokenRepoFactory - ServersRepoFn common.ServersRepoFactory + IamRepoFn common.IamRepoFactory PasswordAuthRepoFn common.PasswordAuthRepoFactory + ServersRepoFn common.ServersRepoFactory + StaticHostRepoFn common.StaticRepoFactory + TargetRepoFn common.TargetRepoFactory kms *kms.Kms @@ -118,6 +120,9 @@ func New(conf *Config) (*Controller, error) { c.PasswordAuthRepoFn = func() (*password.Repository, error) { return password.NewRepository(dbase, dbase, c.kms) } + c.TargetRepoFn = func() (*target.Repository, error) { + return target.NewRepository(dbase, dbase, c.kms) + } c.workerAuthCache = cache.New(0, 0) diff --git a/internal/servers/controller/handler.go b/internal/servers/controller/handler.go index fd7254108..9f115a7d5 100644 --- a/internal/servers/controller/handler.go +++ b/internal/servers/controller/handler.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/boundary/internal/servers/controller/handlers/accounts" "github.com/hashicorp/boundary/internal/servers/controller/handlers/authmethods" "github.com/hashicorp/boundary/internal/servers/controller/handlers/host_sets" + "github.com/hashicorp/boundary/internal/servers/controller/handlers/targets" "github.com/hashicorp/shared-secure-libs/configutil" "github.com/hashicorp/vault/sdk/helper/strutil" @@ -142,6 +143,13 @@ func handleGrpcGateway(c *Controller, props HandlerProperties) (http.Handler, er if err := services.RegisterUserServiceHandlerServer(ctx, mux, us); err != nil { return nil, fmt.Errorf("failed to register user service handler: %w", err) } + ts, err := targets.NewService(c.TargetRepoFn, c.IamRepoFn) + if err != nil { + return nil, fmt.Errorf("failed to create target handler service: %w", err) + } + if err := services.RegisterTargetServiceHandlerServer(ctx, mux, ts); err != nil { + return nil, fmt.Errorf("failed to register target service handler: %w", err) + } gs, err := groups.NewService(c.IamRepoFn) if err != nil { return nil, fmt.Errorf("failed to create group handler service: %w", err) diff --git a/internal/servers/controller/handler_test.go b/internal/servers/controller/handler_test.go index c69dfea19..e236dea86 100644 --- a/internal/servers/controller/handler_test.go +++ b/internal/servers/controller/handler_test.go @@ -95,6 +95,13 @@ func TestHandleImplementedPaths(t *testing.T) { for verb, paths := range map[string][]string{ "GET": { + // new paths + "v1/targets", + "v1/targets/someid", + "v1/host-sets", + "v1/host-sets/someid", + + // old paths "v1/scopes", "v1/scopes/someid", "v1/scopes/someid/auth-tokens", @@ -115,10 +122,20 @@ func TestHandleImplementedPaths(t *testing.T) { "v1/scopes/someid/roles/someid", "v1/scopes/someid/users", "v1/scopes/someid/users/someid", - "v1/host-sets/someid", }, "POST": { // Creation end points + // new paths + "v1/targets", + "v1/targets/someid:add-host-sets", + "v1/targets/someid:set-host-sets", + "v1/targets/someid:remove-host-sets", + "v1/host-sets", + "v1/host-sets/someid:add-hosts", + "v1/host-sets/someid:set-hosts", + "v1/host-sets/someid:remove-hosts", + + // old paths "v1/scopes", "v1/scopes/someid/groups", "v1/scopes/someid/roles", @@ -128,7 +145,6 @@ func TestHandleImplementedPaths(t *testing.T) { "v1/scopes/someid/host-catalogs", "v1/scopes/someid/host-catalogs/someid/host-sets", "v1/scopes/someid/host-catalogs/someid/hosts", - "v1/host-sets", // custom methods "v1/scopes/someid/auth-methods/someid:authenticate", @@ -143,11 +159,13 @@ func TestHandleImplementedPaths(t *testing.T) { "v1/scopes/someid/groups/someid:add-members", "v1/scopes/someid/groups/someid:set-members", "v1/scopes/someid/groups/someid:remove-members", - "v1/host-sets/someid:add-hosts", - "v1/host-sets/someid:set-hosts", - "v1/host-sets/someid:remove-hosts", }, "DELETE": { + // new paths + "v1/targets/someid", + "v1/host-sets/someid", + + // old paths "v1/scopes/someid", "v1/scopes/someid/users/someid", "v1/scopes/someid/roles/someid", @@ -158,9 +176,13 @@ func TestHandleImplementedPaths(t *testing.T) { "v1/scopes/someid/host-catalogs/someid", "v1/scopes/someid/host-catalogs/someid/host-sets/someid", "v1/scopes/someid/host-catalogs/someid/hosts/someid", - "v1/host-sets/someid", }, "PATCH": { + // new paths + "v1/targets/someid", + "v1/host-sets/someid", + + // old paths "v1/scopes/someid", "v1/scopes/someid/users/someid", "v1/scopes/someid/roles/someid", @@ -169,7 +191,6 @@ func TestHandleImplementedPaths(t *testing.T) { "v1/scopes/someid/host-catalogs/someid", "v1/scopes/someid/host-catalogs/someid/host-sets/someid", "v1/scopes/someid/host-catalogs/someid/hosts/someid", - "v1/host-sets/someid", }, } { for _, p := range paths { diff --git a/internal/servers/controller/handlers/host_sets/host_set_service.go b/internal/servers/controller/handlers/host_sets/host_set_service.go index e6624ff96..56952c54a 100644 --- a/internal/servers/controller/handlers/host_sets/host_set_service.go +++ b/internal/servers/controller/handlers/host_sets/host_set_service.go @@ -424,10 +424,10 @@ func (s Service) setInRepo(ctx context.Context, scopeId, setId string, hostIds [ out, m, err := repo.LookupSet(ctx, setId) if err != nil { - return nil, status.Errorf(codes.Internal, "Unable to look up group: %v.", err) + return nil, status.Errorf(codes.Internal, "Unable to look up host set: %v.", err) } if out == nil { - return nil, status.Error(codes.Internal, "Unable to lookup group after setting members for it.") + return nil, status.Error(codes.Internal, "Unable to lookup host set after setting hosts for it.") } return toProto(out, m), nil } diff --git a/internal/servers/controller/handlers/mask_manager.go b/internal/servers/controller/handlers/mask_manager.go index 0b16e6821..5f0ab6b84 100644 --- a/internal/servers/controller/handlers/mask_manager.go +++ b/internal/servers/controller/handlers/mask_manager.go @@ -81,3 +81,12 @@ func (m MaskManager) Translate(paths []string) []string { } return result } + +func MaskContains(paths []string, s string) bool { + for _, p := range paths { + if p == s { + return true + } + } + return false +} diff --git a/internal/servers/controller/handlers/targets/target_service.go b/internal/servers/controller/handlers/targets/target_service.go new file mode 100644 index 000000000..1e29cb376 --- /dev/null +++ b/internal/servers/controller/handlers/targets/target_service.go @@ -0,0 +1,532 @@ +package targets + +import ( + "context" + "errors" + "fmt" + + "github.com/hashicorp/boundary/internal/auth" + "github.com/hashicorp/boundary/internal/db" + pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/targets" + pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services" + "github.com/hashicorp/boundary/internal/iam" + "github.com/hashicorp/boundary/internal/servers/controller/handlers" + "github.com/hashicorp/boundary/internal/target" + "github.com/hashicorp/boundary/internal/target/store" + "github.com/hashicorp/boundary/internal/types/action" + "github.com/hashicorp/boundary/internal/types/scope" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/wrapperspb" +) + +var ( + maskManager handlers.MaskManager +) + +func init() { + var err error + if maskManager, err = handlers.NewMaskManager(&store.TcpTarget{}, &pb.Target{}); err != nil { + panic(err) + } +} + +// Service handles request as described by the pbs.TargetServiceServer interface. +type Service struct { + repoFn func() (*target.Repository, error) + iamRepoFn func() (*iam.Repository, error) +} + +// NewService returns a target service which handles target related requests to boundary. +func NewService(repoFn func() (*target.Repository, error), iamRepoFn func() (*iam.Repository, error)) (Service, error) { + if repoFn == nil { + return Service{}, fmt.Errorf("nil target repository provided") + } + if iamRepoFn == nil { + return Service{}, fmt.Errorf("nil target repository provided") + } + return Service{repoFn: repoFn, iamRepoFn: iamRepoFn}, nil +} + +var _ pbs.TargetServiceServer = Service{} + +// ListTargets implements the interface pbs.TargetServiceServer. +func (s Service) ListTargets(ctx context.Context, req *pbs.ListTargetsRequest) (*pbs.ListTargetsResponse, error) { + if err := validateListRequest(req); err != nil { + return nil, err + } + authResults := s.collectionAuthVerify(ctx, req.GetScopeId(), action.List) + if authResults.Error != nil { + return nil, authResults.Error + } + ul, err := s.listFromRepo(ctx, authResults.Scope.GetId()) + if err != nil { + return nil, err + } + for _, item := range ul { + item.Scope = authResults.Scope + } + return &pbs.ListTargetsResponse{Items: ul}, nil +} + +// GetTargets implements the interface pbs.TargetServiceServer. +func (s Service) GetTarget(ctx context.Context, req *pbs.GetTargetRequest) (*pbs.GetTargetResponse, error) { + if err := validateGetRequest(req); err != nil { + return nil, err + } + authResults := s.authVerify(ctx, req.GetId(), action.Read) + if authResults.Error != nil { + return nil, authResults.Error + } + u, err := s.getFromRepo(ctx, req.GetId()) + if err != nil { + return nil, err + } + u.Scope = authResults.Scope + return &pbs.GetTargetResponse{Item: u}, nil +} + +// CreateTarget implements the interface pbs.TargetServiceServer. +func (s Service) CreateTarget(ctx context.Context, req *pbs.CreateTargetRequest) (*pbs.CreateTargetResponse, error) { + if err := validateCreateRequest(req); err != nil { + return nil, err + } + authResults := s.collectionAuthVerify(ctx, req.GetItem().GetScopeId(), action.Create) + if authResults.Error != nil { + return nil, authResults.Error + } + u, err := s.createInRepo(ctx, req.GetItem()) + if err != nil { + return nil, err + } + u.Scope = authResults.Scope + return &pbs.CreateTargetResponse{Item: u, Uri: fmt.Sprintf("targets/%s", u.GetId())}, nil +} + +// UpdateTarget implements the interface pbs.TargetServiceServer. +func (s Service) UpdateTarget(ctx context.Context, req *pbs.UpdateTargetRequest) (*pbs.UpdateTargetResponse, error) { + if err := validateUpdateRequest(req); err != nil { + return nil, err + } + authResults := s.authVerify(ctx, req.GetId(), action.Update) + if authResults.Error != nil { + return nil, authResults.Error + } + u, err := s.updateInRepo(ctx, authResults.Scope.GetId(), req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem()) + if err != nil { + return nil, err + } + u.Scope = authResults.Scope + return &pbs.UpdateTargetResponse{Item: u}, nil +} + +// DeleteTarget implements the interface pbs.TargetServiceServer. +func (s Service) DeleteTarget(ctx context.Context, req *pbs.DeleteTargetRequest) (*pbs.DeleteTargetResponse, error) { + if err := validateDeleteRequest(req); err != nil { + return nil, err + } + authResults := s.authVerify(ctx, req.GetId(), action.Delete) + if authResults.Error != nil { + return nil, authResults.Error + } + existed, err := s.deleteFromRepo(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &pbs.DeleteTargetResponse{Existed: existed}, nil +} + +// AddTargetHostSets implements the interface pbs.TargetServiceServer. +func (s Service) AddTargetHostSets(ctx context.Context, req *pbs.AddTargetHostSetsRequest) (*pbs.AddTargetHostSetsResponse, error) { + if err := validateAddRequest(req); err != nil { + return nil, err + } + authResults := s.authVerify(ctx, req.GetId(), action.AddHostSets) + if authResults.Error != nil { + return nil, authResults.Error + } + u, err := s.addInRepo(ctx, req.GetId(), req.GetHostSetIds(), req.GetVersion()) + if err != nil { + return nil, err + } + u.Scope = authResults.Scope + return &pbs.AddTargetHostSetsResponse{Item: u}, nil +} + +// SetTargetHostSets implements the interface pbs.TargetServiceServer. +func (s Service) SetTargetHostSets(ctx context.Context, req *pbs.SetTargetHostSetsRequest) (*pbs.SetTargetHostSetsResponse, error) { + if err := validateSetRequest(req); err != nil { + return nil, err + } + authResults := s.authVerify(ctx, req.GetId(), action.SetHostSets) + if authResults.Error != nil { + return nil, authResults.Error + } + u, err := s.setInRepo(ctx, req.GetId(), req.GetHostSetIds(), req.GetVersion()) + if err != nil { + return nil, err + } + u.Scope = authResults.Scope + return &pbs.SetTargetHostSetsResponse{Item: u}, nil +} + +// RemoveTargetHostSets implements the interface pbs.TargetServiceServer. +func (s Service) RemoveTargetHostSets(ctx context.Context, req *pbs.RemoveTargetHostSetsRequest) (*pbs.RemoveTargetHostSetsResponse, error) { + if err := validateRemoveRequest(req); err != nil { + return nil, err + } + authResults := s.authVerify(ctx, req.GetId(), action.RemoveHostSets) + if authResults.Error != nil { + return nil, authResults.Error + } + u, err := s.removeInRepo(ctx, req.GetId(), req.GetHostSetIds(), req.GetVersion()) + if err != nil { + return nil, err + } + u.Scope = authResults.Scope + return &pbs.RemoveTargetHostSetsResponse{Item: u}, nil +} + +func (s Service) getFromRepo(ctx context.Context, id string) (*pb.Target, error) { + repo, err := s.repoFn() + if err != nil { + return nil, err + } + u, m, err := repo.LookupTarget(ctx, id) + if err != nil { + if errors.Is(err, db.ErrRecordNotFound) { + return nil, handlers.NotFoundErrorf("Target %q doesn't exist.", id) + } + return nil, err + } + if u == nil { + return nil, handlers.NotFoundErrorf("Target %q doesn't exist.", id) + } + return toProto(u, m), nil +} + +func (s Service) createInRepo(ctx context.Context, item *pb.Target) (*pb.Target, error) { + opts := []target.Option{target.WithName(item.GetName().GetValue())} + if item.GetDescription() != nil { + opts = append(opts, target.WithDescription(item.GetDescription().GetValue())) + } + if item.GetDefaultPort().GetValue() != 0 { + opts = append(opts, target.WithDefaultPort(item.GetDefaultPort().GetValue())) + } + u, err := target.NewTcpTarget(item.GetScopeId(), opts...) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to build target for creation: %v.", err) + } + repo, err := s.repoFn() + if err != nil { + return nil, err + } + out, m, err := repo.CreateTcpTarget(ctx, u) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to create target: %v.", err) + } + if out == nil { + return nil, status.Error(codes.Internal, "Unable to create target but no error returned from repository.") + } + return toProto(out, m), nil +} + +func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []string, item *pb.Target) (*pb.Target, error) { + var opts []target.Option + if desc := item.GetDescription(); desc != nil { + opts = append(opts, target.WithDescription(desc.GetValue())) + } + if name := item.GetName(); name != nil { + opts = append(opts, target.WithName(name.GetValue())) + } + version := item.GetVersion() + u, err := target.NewTcpTarget(scopeId, opts...) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to build target for update: %v.", err) + } + u.PublicId = id + dbMask := maskManager.Translate(mask) + if len(dbMask) == 0 { + return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid paths provided in the update mask."}) + } + repo, err := s.repoFn() + if err != nil { + return nil, err + } + out, m, rowsUpdated, err := repo.UpdateTcpTarget(ctx, u, version, dbMask) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to update target: %v.", err) + } + if rowsUpdated == 0 { + return nil, handlers.NotFoundErrorf("Target %q doesn't exist.", id) + } + return toProto(out, m), nil +} + +func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) { + repo, err := s.repoFn() + if err != nil { + return false, err + } + rows, err := repo.DeleteTarget(ctx, id) + if err != nil { + if errors.Is(err, db.ErrRecordNotFound) { + return false, nil + } + return false, status.Errorf(codes.Internal, "Unable to delete target: %v.", err) + } + return rows > 0, nil +} + +func (s Service) listFromRepo(ctx context.Context, scopeId string) ([]*pb.Target, error) { + repo, err := s.repoFn() + if err != nil { + return nil, err + } + ul, err := repo.ListTargets(ctx, target.WithScopeId(scopeId)) + if err != nil { + return nil, err + } + var outUl []*pb.Target + for _, u := range ul { + outUl = append(outUl, toProto(u, nil)) + } + return outUl, nil +} + +func (s Service) addInRepo(ctx context.Context, targetId string, hostSetId []string, version uint32) (*pb.Target, error) { + repo, err := s.repoFn() + if err != nil { + return nil, err + } + out, m, err := repo.AddTargeHostSets(ctx, targetId, version, hostSetId) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to add host sets to target: %v.", err) + } + if out == nil { + return nil, status.Error(codes.Internal, "Unable to lookup target after adding host sets to it.") + } + return toProto(out, m), nil +} + +func (s Service) setInRepo(ctx context.Context, targetId string, hostSetIds []string, version uint32) (*pb.Target, error) { + repo, err := s.repoFn() + if err != nil { + return nil, err + } + _, _, err = repo.SetTargetHostSets(ctx, targetId, version, hostSetIds) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to set host sets in target: %v.", err) + } + + out, m, err := repo.LookupTarget(ctx, targetId) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to look up target: %v.", err) + } + if out == nil { + return nil, status.Error(codes.Internal, "Unable to lookup target after setting host sets for it.") + } + return toProto(out, m), nil +} + +func (s Service) removeInRepo(ctx context.Context, targetId string, hostSetIds []string, version uint32) (*pb.Target, error) { + repo, err := s.repoFn() + if err != nil { + return nil, err + } + _, err = repo.DeleteTargeHostSets(ctx, targetId, version, hostSetIds) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to remove host sets from target: %v.", err) + } + out, m, err := repo.LookupTarget(ctx, targetId) + if err != nil { + return nil, status.Errorf(codes.Internal, "Unable to look up target: %v.", err) + } + if out == nil { + return nil, status.Error(codes.Internal, "Unable to lookup target after removing host sets from it.") + } + return toProto(out, m), nil +} + +func (s Service) collectionAuthVerify(ctx context.Context, parentId string, a action.Type) auth.VerifyResults { + var res auth.VerifyResults + iamRep, err := s.iamRepoFn() + if err != nil { + res.Error = err + return res + } + sc, err := iamRep.LookupScope(ctx, parentId) + if err != nil { + res.Error = err + return res + } + if sc == nil { + res.Error = handlers.ForbiddenError() + return res + } + authResults := auth.Verify(ctx, + auth.WithScopeId(sc.GetPublicId()), + auth.WithAction(a)) + return authResults +} + +func (s Service) authVerify(ctx context.Context, id string, a action.Type) auth.VerifyResults { + var res auth.VerifyResults + repo, err := s.repoFn() + if err != nil { + res.Error = err + return res + } + tar, _, err := repo.LookupTarget(ctx, id) + if err != nil { + res.Error = err + return res + } + if tar == nil { + res.Error = handlers.ForbiddenError() + return res + } + authResults := auth.Verify(ctx, + auth.WithScopeId(tar.GetScopeId()), + auth.WithAction(a)) + return authResults +} + +func toProto(in target.Target, m []*target.TargetSet) *pb.Target { + out := pb.Target{ + Id: in.GetPublicId(), + ScopeId: in.GetScopeId(), + CreatedTime: in.GetCreateTime().GetTimestamp(), + UpdatedTime: in.GetUpdateTime().GetTimestamp(), + Version: in.GetVersion(), + Type: target.TcpTargetType.String(), + } + if in.GetDescription() != "" { + out.Description = wrapperspb.String(in.GetDescription()) + } + if in.GetName() != "" { + out.Name = wrapperspb.String(in.GetName()) + } + if in.GetDefaultPort() != 0 { + out.DefaultPort = wrapperspb.UInt32(in.GetDefaultPort()) + } + for _, hs := range m { + out.HostSetIds = append(out.HostSetIds, hs.GetPublicId()) + out.HostSets = append(out.HostSets, &pb.HostSet{ + Id: hs.GetPublicId(), + HostCatalogId: hs.GetCatalogId(), + }) + } + return &out +} + +// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce +// requirements on the structure of the request. They verify that: +// * The path passed in is correctly formatted +// * All required parameters are set +// * There are no conflicting parameters provided +func validateGetRequest(req *pbs.GetTargetRequest) error { + return handlers.ValidateGetRequest(target.TcpTargetPrefix, req, handlers.NoopValidatorFn) +} + +func validateCreateRequest(req *pbs.CreateTargetRequest) error { + return handlers.ValidateCreateRequest(req.GetItem(), func() map[string]string { + badFields := map[string]string{} + if !handlers.ValidId(scope.Project.Prefix(), req.GetItem().GetScopeId()) { + badFields["scope_id"] = "This field is required to have a properly formatted project scope id." + } + if req.GetItem().GetName() == nil || req.GetItem().GetName().GetValue() == "" { + badFields["name"] = "This field is required." + } + if req.GetItem().GetDefaultPort() != nil && req.GetItem().GetDefaultPort().GetValue() == 0 { + badFields["default_port"] = "This optional field cannot be set to 0." + } + switch req.GetItem().GetType() { + case target.TcpTargetType.String(): + case "": + badFields["type"] = "This is a required field." + default: + badFields["type"] = "Unknown type provided." + } + return badFields + }) +} + +func validateUpdateRequest(req *pbs.UpdateTargetRequest) error { + return handlers.ValidateUpdateRequest(target.TcpTargetPrefix, req, req.GetItem(), func() map[string]string { + badFields := map[string]string{} + if handlers.MaskContains(req.GetUpdateMask().GetPaths(), "name") && req.GetItem().GetName().GetValue() == "" { + badFields["name"] = "This field cannot be set to empty." + } + if req.GetItem().GetDefaultPort() != nil && req.GetItem().GetDefaultPort().GetValue() == 0 { + badFields["default_port"] = "This optional field cannot be set to 0." + } + if req.GetItem().GetType() != "" { + badFields["type"] = "This field cannot be updated." + } + return badFields + }) +} + +func validateDeleteRequest(req *pbs.DeleteTargetRequest) error { + return handlers.ValidateDeleteRequest(target.TcpTargetPrefix, req, handlers.NoopValidatorFn) +} + +func validateListRequest(req *pbs.ListTargetsRequest) error { + badFields := map[string]string{} + if !handlers.ValidId(scope.Project.Prefix(), req.GetScopeId()) { + badFields["scope_id"] = "This field is required to have a properly formatted project scope id." + } + if len(badFields) > 0 { + return handlers.InvalidArgumentErrorf("Improperly formatted identifier.", badFields) + } + return nil +} + +func validateAddRequest(req *pbs.AddTargetHostSetsRequest) error { + badFields := map[string]string{} + if !handlers.ValidId(target.TcpTargetPrefix, req.GetId()) { + badFields["id"] = "Incorrectly formatted identifier." + } + if req.GetVersion() == 0 { + badFields["version"] = "Required field." + } + if len(req.GetHostSetIds()) == 0 { + badFields["host_set_ids"] = "Must be non-empty." + } + if len(badFields) > 0 { + return handlers.InvalidArgumentErrorf("Errors in provided fields.", badFields) + } + return nil +} + +func validateSetRequest(req *pbs.SetTargetHostSetsRequest) error { + badFields := map[string]string{} + if !handlers.ValidId(target.TcpTargetPrefix, req.GetId()) { + badFields["id"] = "Incorrectly formatted identifier." + } + if req.GetVersion() == 0 { + badFields["version"] = "Required field." + } + if len(badFields) > 0 { + return handlers.InvalidArgumentErrorf("Errors in provided fields.", badFields) + } + return nil +} + +func validateRemoveRequest(req *pbs.RemoveTargetHostSetsRequest) error { + badFields := map[string]string{} + if !handlers.ValidId(target.TcpTargetPrefix, req.GetId()) { + badFields["id"] = "Incorrectly formatted identifier." + } + if req.GetVersion() == 0 { + badFields["version"] = "Required field." + } + if len(req.GetHostSetIds()) == 0 { + badFields["host_set_ids"] = "Must be non-empty." + } + if len(badFields) > 0 { + return handlers.InvalidArgumentErrorf("Errors in provided fields.", badFields) + } + return nil +} diff --git a/internal/servers/controller/handlers/targets/target_service_test.go b/internal/servers/controller/handlers/targets/target_service_test.go new file mode 100644 index 000000000..d19a7f3e0 --- /dev/null +++ b/internal/servers/controller/handlers/targets/target_service_test.go @@ -0,0 +1,1063 @@ +package targets_test + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/golang/protobuf/ptypes" + "github.com/google/go-cmp/cmp" + "github.com/hashicorp/boundary/internal/auth" + "github.com/hashicorp/boundary/internal/db" + "github.com/hashicorp/boundary/internal/gen/controller/api/resources/scopes" + pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/targets" + pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services" + "github.com/hashicorp/boundary/internal/host/static" + "github.com/hashicorp/boundary/internal/iam" + "github.com/hashicorp/boundary/internal/kms" + "github.com/hashicorp/boundary/internal/servers/controller/handlers/targets" + "github.com/hashicorp/boundary/internal/target" + "github.com/hashicorp/boundary/internal/types/scope" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/genproto/protobuf/field_mask" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/testing/protocmp" + "google.golang.org/protobuf/types/known/wrapperspb" +) + +func TestGet(t *testing.T) { + t.Parallel() + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] + hs := static.TestSets(t, conn, hc.GetPublicId(), 2) + + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "test", target.WithHostSets([]string{hs[0].GetPublicId(), hs[1].GetPublicId()})) + + pTar := &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: proj.GetPublicId(), + Name: wrapperspb.String("test"), + CreatedTime: tar.CreateTime.GetTimestamp(), + UpdatedTime: tar.UpdateTime.GetTimestamp(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Type: target.TcpTargetType.String(), + HostSetIds: []string{hs[0].GetPublicId(), hs[1].GetPublicId()}, + } + for _, ihs := range hs { + pTar.HostSets = append(pTar.HostSets, &pb.HostSet{Id: ihs.GetPublicId(), HostCatalogId: ihs.GetCatalogId()}) + } + + cases := []struct { + name string + req *pbs.GetTargetRequest + res *pbs.GetTargetResponse + errCode codes.Code + }{ + { + name: "Get an Existing Target", + req: &pbs.GetTargetRequest{Id: tar.GetPublicId()}, + res: &pbs.GetTargetResponse{Item: pTar}, + errCode: codes.OK, + }, + { + name: "Get a non existing Target", + req: &pbs.GetTargetRequest{Id: target.TcpTargetPrefix + "_DoesntExis"}, + res: nil, + errCode: codes.PermissionDenied, + }, + { + name: "Wrong id prefix", + req: &pbs.GetTargetRequest{Id: "j_1234567890"}, + res: nil, + errCode: codes.InvalidArgument, + }, + { + name: "space in id", + req: &pbs.GetTargetRequest{Id: target.TcpTargetPrefix + "_1 23456789"}, + res: nil, + errCode: codes.InvalidArgument, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert := assert.New(t) + + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Couldn't create a new host set service.") + + got, gErr := s.GetTarget(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), tc.req) + assert.Equal(tc.errCode, status.Code(gErr), "GetTarget(%+v) got error %v, wanted %v", tc.req, gErr, tc.errCode) + + if tc.res != nil { + tc.res.Item.Version = 1 + } + assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform()), "GetTarget(%q) got response %q, wanted %q", tc.req, got, tc.res) + }) + } +} + +func TestList(t *testing.T) { + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + _, projNoTar := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] + hss := static.TestSets(t, conn, hc.GetPublicId(), 2) + + var wantTars []*pb.Target + for i := 0; i < 5; i++ { + name := fmt.Sprintf("tar%d", i) + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), name, target.WithHostSets([]string{hss[0].GetPublicId(), hss[1].GetPublicId()})) + wantTars = append(wantTars, &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: proj.GetPublicId(), + Name: wrapperspb.String(name), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + CreatedTime: tar.GetCreateTime().GetTimestamp(), + UpdatedTime: tar.GetUpdateTime().GetTimestamp(), + Version: tar.GetVersion(), + Type: target.TcpTargetType.String(), + }) + } + + cases := []struct { + name string + scopeId string + res *pbs.ListTargetsResponse + errCode codes.Code + }{ + { + name: "List Many Host Sets", + scopeId: proj.GetPublicId(), + res: &pbs.ListTargetsResponse{Items: wantTars}, + errCode: codes.OK, + }, + { + name: "List No Host Sets", + scopeId: projNoTar.GetPublicId(), + res: &pbs.ListTargetsResponse{}, + errCode: codes.OK, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert, require := assert.New(t), require.New(t) + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(err, "Couldn't create new host set service.") + + got, gErr := s.ListTargets(auth.DisabledAuthTestContext(auth.WithScopeId(tc.scopeId)), &pbs.ListTargetsRequest{ScopeId: tc.scopeId}) + assert.Equal(tc.errCode, status.Code(gErr), "ListTargets(%q) got error %v, wanted %v", tc.scopeId, gErr, tc.errCode) + assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform()), "ListTargets(%q) got response %q, wanted %q", tc.scopeId, got, tc.res) + }) + } +} + +func TestDelete(t *testing.T) { + t.Parallel() + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "test") + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Couldn't create a new target service.") + + cases := []struct { + name string + scopeId string + req *pbs.DeleteTargetRequest + res *pbs.DeleteTargetResponse + errCode codes.Code + }{ + { + name: "Delete an Existing Target", + scopeId: proj.GetPublicId(), + req: &pbs.DeleteTargetRequest{ + Id: tar.GetPublicId(), + }, + res: &pbs.DeleteTargetResponse{ + Existed: true, + }, + errCode: codes.OK, + }, + { + name: "Delete Not Existing Target", + scopeId: proj.GetPublicId(), + req: &pbs.DeleteTargetRequest{ + Id: target.TcpTargetPrefix + "_doesntexis", + }, + res: nil, + errCode: codes.PermissionDenied, + }, + { + name: "Bad target id formatting", + scopeId: proj.GetPublicId(), + req: &pbs.DeleteTargetRequest{ + Id: target.TcpTargetPrefix + "_bad_format", + }, + res: nil, + errCode: codes.InvalidArgument, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert := assert.New(t) + got, gErr := s.DeleteTarget(auth.DisabledAuthTestContext(auth.WithScopeId(tc.scopeId)), tc.req) + assert.Equal(tc.errCode, status.Code(gErr), "DeleteTarget(%+v) got error %v, wanted %v", tc.req, gErr, tc.errCode) + assert.Empty(cmp.Diff(tc.res, got, protocmp.Transform()), "DeleteTarget(%q) got response %q, wanted %q", tc.req, got, tc.res) + }) + } +} + +func TestDelete_twice(t *testing.T) { + t.Parallel() + assert := assert.New(t) + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "test") + + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Couldn't create a new target service.") + req := &pbs.DeleteTargetRequest{ + Id: tar.GetPublicId(), + } + ctx := auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())) + got, gErr := s.DeleteTarget(ctx, req) + assert.NoError(gErr, "First attempt") + assert.True(got.GetExisted(), "Expected existed to be true for the first delete.") + _, gErr = s.DeleteTarget(ctx, req) + assert.Error(gErr, "Second attempt") + assert.Equal(codes.PermissionDenied, status.Code(gErr), "Expected permission denied for the second delete.") +} + +func TestCreate(t *testing.T) { + t.Parallel() + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + + cases := []struct { + name string + req *pbs.CreateTargetRequest + res *pbs.CreateTargetResponse + errCode codes.Code + }{ + { + name: "Create a valid target", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + ScopeId: proj.GetPublicId(), + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(2), + }}, + res: &pbs.CreateTargetResponse{ + Uri: fmt.Sprintf("targets/%s_", target.TcpTargetPrefix), + Item: &pb.Target{ + ScopeId: proj.GetPublicId(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(2), + }, + }, + errCode: codes.OK, + }, + { + name: "Create with default port 0", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(0), + }}, + errCode: codes.InvalidArgument, + }, + { + name: "Create with unknown type", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + Type: "ThisIsMadeUp", + }}, + errCode: codes.InvalidArgument, + }, + { + name: "Create with no type", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + }}, + errCode: codes.InvalidArgument, + }, + { + name: "Can't specify Id", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + Id: "not allowed to be set", + }}, + res: nil, + errCode: codes.InvalidArgument, + }, + { + name: "Can't specify Created Time", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + CreatedTime: ptypes.TimestampNow(), + }}, + res: nil, + errCode: codes.InvalidArgument, + }, + { + name: "Can't specify Update Time", + req: &pbs.CreateTargetRequest{Item: &pb.Target{ + UpdatedTime: ptypes.TimestampNow(), + }}, + res: nil, + errCode: codes.InvalidArgument, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert, require := assert.New(t), require.New(t) + + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(err, "Failed to create a new host set service.") + + got, gErr := s.CreateTarget(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), tc.req) + assert.Equal(tc.errCode, status.Code(gErr), "CreateTarget(%+v) got error %v, wanted %v", tc.req, gErr, tc.errCode) + if got != nil { + assert.Contains(got.GetUri(), tc.res.GetUri()) + assert.True(strings.HasPrefix(got.GetItem().GetId(), target.TcpTargetPrefix), got.GetItem().GetId()) + + // Clear all values which are hard to compare against. + got.Uri, tc.res.Uri = "", "" + got.Item.Id, tc.res.Item.Id = "", "" + got.Item.CreatedTime, got.Item.UpdatedTime, tc.res.Item.CreatedTime, tc.res.Item.UpdatedTime = nil, nil, nil, nil + } + if tc.res != nil { + tc.res.Item.Version = 1 + } + assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform()), "CreateTarget(%q) got response %q, wanted %q", tc.req, got, tc.res) + }) + } +} + +func TestUpdate(t *testing.T) { + t.Parallel() + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + repo, err := repoFn() + require.NoError(t, err, "Couldn't create new target repo.") + + hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] + hs := static.TestSets(t, conn, hc.GetPublicId(), 2) + hsIds := []string{hs[0].GetPublicId(), hs[1].GetPublicId()} + hostSets := []*pb.HostSet{ + {Id: hs[0].GetPublicId(), HostCatalogId: hs[0].GetCatalogId()}, + {Id: hs[1].GetPublicId(), HostCatalogId: hs[1].GetCatalogId()}, + } + + tar, err := target.NewTcpTarget(proj.GetPublicId(), target.WithName("default"), target.WithDescription("default")) + tar.DefaultPort = 2 + require.NoError(t, err) + gtar, _, err := repo.CreateTcpTarget(context.Background(), tar, target.WithHostSets([]string{hs[0].GetPublicId(), hs[1].GetPublicId()})) + require.NoError(t, err) + tar = gtar.(*target.TcpTarget) + + var version uint32 = 1 + + resetTarget := func() { + version++ + _, _, _, err = repo.UpdateTcpTarget(context.Background(), tar, version, []string{"Name", "Description"}) + require.NoError(t, err, "Failed to reset target.") + version++ + } + + hCreated, err := ptypes.Timestamp(tar.GetCreateTime().GetTimestamp()) + require.NoError(t, err, "Failed to convert proto to timestamp") + toMerge := &pbs.UpdateTargetRequest{ + Id: tar.GetPublicId(), + } + + tested, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Failed to create a new host set service.") + + cases := []struct { + name string + req *pbs.UpdateTargetRequest + res *pbs.UpdateTargetResponse + errCode codes.Code + }{ + { + name: "Update an Existing Target", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"name", "description"}, + }, + Item: &pb.Target{ + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + }, + }, + res: &pbs.UpdateTargetResponse{ + Item: &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: tar.GetScopeId(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(2), + CreatedTime: tar.GetCreateTime().GetTimestamp(), + HostSetIds: hsIds, + HostSets: hostSets, + }, + }, + errCode: codes.OK, + }, + { + name: "Multiple Paths in single string", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"name,description"}, + }, + Item: &pb.Target{ + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + }, + }, + res: &pbs.UpdateTargetResponse{ + Item: &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: tar.GetScopeId(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("name"), + Description: wrapperspb.String("desc"), + CreatedTime: tar.GetCreateTime().GetTimestamp(), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(2), + HostSetIds: hsIds, + HostSets: hostSets, + }, + }, + errCode: codes.OK, + }, + { + name: "No Update Mask", + req: &pbs.UpdateTargetRequest{ + Item: &pb.Target{ + Name: wrapperspb.String("updated name"), + Description: wrapperspb.String("updated desc"), + }, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Empty Path", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{Paths: []string{}}, + Item: &pb.Target{ + Name: wrapperspb.String("updated name"), + Description: wrapperspb.String("updated desc"), + }, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Update port to 0", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{Paths: []string{"default_port"}}, + Item: &pb.Target{ + DefaultPort: wrapperspb.UInt32(0), + }, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Only non-existant paths in Mask", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{Paths: []string{"nonexistant_field"}}, + Item: &pb.Target{ + Name: wrapperspb.String("updated name"), + Description: wrapperspb.String("updated desc"), + }, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Unset Name", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"name"}, + }, + Item: &pb.Target{ + Description: wrapperspb.String("ignored"), + }, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Unset Description", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"description"}, + }, + Item: &pb.Target{ + Name: wrapperspb.String("ignored"), + }, + }, + res: &pbs.UpdateTargetResponse{ + Item: &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: tar.GetScopeId(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("default"), + CreatedTime: tar.GetCreateTime().GetTimestamp(), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(2), + HostSetIds: hsIds, + HostSets: hostSets, + }, + }, + errCode: codes.OK, + }, + { + name: "Update Only Name", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"name"}, + }, + Item: &pb.Target{ + Name: wrapperspb.String("updated"), + Description: wrapperspb.String("ignored"), + }, + }, + res: &pbs.UpdateTargetResponse{ + Item: &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: tar.GetScopeId(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("updated"), + Description: wrapperspb.String("default"), + CreatedTime: tar.GetCreateTime().GetTimestamp(), + Type: target.TcpTargetType.String(), + DefaultPort: wrapperspb.UInt32(2), + HostSetIds: hsIds, + HostSets: hostSets, + }, + }, + errCode: codes.OK, + }, + { + name: "Update Only Description", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"description"}, + }, + Item: &pb.Target{ + Name: wrapperspb.String("ignored"), + Description: wrapperspb.String("notignored"), + }, + }, + res: &pbs.UpdateTargetResponse{ + Item: &pb.Target{ + Id: tar.GetPublicId(), + ScopeId: tar.GetScopeId(), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("default"), + Description: wrapperspb.String("notignored"), + CreatedTime: tar.GetCreateTime().GetTimestamp(), + DefaultPort: wrapperspb.UInt32(2), + Type: target.TcpTargetType.String(), + HostSetIds: hsIds, + HostSets: hostSets, + }, + }, + errCode: codes.OK, + }, + { + name: "Update a Non Existing Target", + req: &pbs.UpdateTargetRequest{ + Id: target.TcpTargetPrefix + "_DoesntExis", + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"description"}, + }, + Item: &pb.Target{ + Name: wrapperspb.String("new"), + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Description: wrapperspb.String("desc"), + }, + }, + errCode: codes.PermissionDenied, + }, + { + name: "Cant change Id", + req: &pbs.UpdateTargetRequest{ + Id: hc.GetPublicId(), + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"id"}, + }, + Item: &pb.Target{ + Id: "p_somethinge", + Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String()}, + Name: wrapperspb.String("new"), + Description: wrapperspb.String("new desc"), + }}, + res: nil, + errCode: codes.InvalidArgument, + }, + { + name: "Cant specify Created Time", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"created_time"}, + }, + Item: &pb.Target{ + CreatedTime: ptypes.TimestampNow(), + }, + }, + res: nil, + errCode: codes.InvalidArgument, + }, + { + name: "Cant specify Updated Time", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"updated_time"}, + }, + Item: &pb.Target{ + UpdatedTime: ptypes.TimestampNow(), + }, + }, + res: nil, + errCode: codes.InvalidArgument, + }, + { + name: "Valid mask, cant specify type", + req: &pbs.UpdateTargetRequest{ + UpdateMask: &field_mask.FieldMask{ + Paths: []string{"name"}, + }, + Item: &pb.Target{ + Type: "Unknown", + }, + }, + res: nil, + errCode: codes.InvalidArgument, + }, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert, require := assert.New(t), require.New(t) + tc.req.Item.Version = version + + req := proto.Clone(toMerge).(*pbs.UpdateTargetRequest) + proto.Merge(req, tc.req) + + // Test some bad versions + req.Item.Version = version + 2 + _, gErr := tested.UpdateTarget(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), req) + require.Error(gErr) + req.Item.Version = version - 1 + _, gErr = tested.UpdateTarget(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), req) + require.Error(gErr) + req.Item.Version = version + + got, gErr := tested.UpdateTarget(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), req) + assert.Equal(tc.errCode, status.Code(gErr), "UpdateTarget(%+v) got error %v, wanted %v", req, gErr, tc.errCode) + + if tc.errCode == codes.OK { + defer resetTarget() + } + + if got != nil { + assert.NotNilf(tc.res, "Expected UpdateHost response to be nil, but was %v", got) + gotUpdateTime, err := ptypes.Timestamp(got.GetItem().GetUpdatedTime()) + require.NoError(err, "Failed to convert proto to timestamp") + // Verify it is a set updated after it was created + // TODO: This is currently failing. + assert.True(gotUpdateTime.After(hCreated), "Updated target should have been updated after it's creation. Was updated %v, which is after %v", gotUpdateTime, hCreated) + + // Clear all values which are hard to compare against. + got.Item.UpdatedTime, tc.res.Item.UpdatedTime = nil, nil + } + if tc.res != nil { + tc.res.Item.Version = version + 1 + } + assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform()), "UpdateTarget(%q) got response %q, wanted %q", req, got, tc.res) + }) + } +} + +func TestAddTargetHostSets(t *testing.T) { + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Error when getting new target service.") + + hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] + hs := static.TestSets(t, conn, hc.GetPublicId(), 2) + + addCases := []struct { + name string + tar *target.TcpTarget + addHostSets []string + resultHostSets []string + }{ + { + name: "Add set on empty target", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "empty"), + addHostSets: []string{hs[1].GetPublicId()}, + resultHostSets: []string{hs[1].GetPublicId()}, + }, + { + name: "Add host on populated target", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "populated", target.WithHostSets([]string{hs[0].GetPublicId()})), + addHostSets: []string{hs[1].GetPublicId()}, + resultHostSets: []string{hs[0].GetPublicId(), hs[1].GetPublicId()}, + }, + } + + for _, tc := range addCases { + t.Run(tc.name, func(t *testing.T) { + req := &pbs.AddTargetHostSetsRequest{ + Id: tc.tar.GetPublicId(), + Version: tc.tar.GetVersion(), + HostSetIds: tc.addHostSets, + } + + got, err := s.AddTargetHostSets(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), req) + s, ok := status.FromError(err) + require.True(t, ok) + require.NoError(t, err, "Got error: %v", s) + + assert.ElementsMatch(t, tc.resultHostSets, got.GetItem().GetHostSetIds()) + }) + } + + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "test") + + failCases := []struct { + name string + req *pbs.AddTargetHostSetsRequest + errCode codes.Code + }{ + { + name: "Bad Set Id", + req: &pbs.AddTargetHostSetsRequest{ + Id: "bad id", + Version: tar.GetVersion(), + HostSetIds: []string{hs[0].GetPublicId()}, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Bad version", + req: &pbs.AddTargetHostSetsRequest{ + Id: tar.GetPublicId(), + Version: tar.GetVersion() + 2, + HostSetIds: []string{hs[0].GetPublicId()}, + }, + errCode: codes.Internal, + }, + { + name: "Empty host set list", + req: &pbs.AddTargetHostSetsRequest{ + Id: tar.GetPublicId(), + Version: tar.GetVersion(), + }, + errCode: codes.InvalidArgument, + }, + } + for _, tc := range failCases { + t.Run(tc.name, func(t *testing.T) { + assert := assert.New(t) + _, gErr := s.AddTargetHostSets(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), tc.req) + assert.Equal(tc.errCode, status.Code(gErr), "AddTargetHostSets(%+v) got error %v, wanted %v", tc.req, gErr, tc.errCode) + }) + } +} + +func TestSetTargetHostSets(t *testing.T) { + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + rw := db.New(conn) + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Error when getting new host set service.") + + hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] + hs := static.TestSets(t, conn, hc.GetPublicId(), 2) + + setCases := []struct { + name string + tar *target.TcpTarget + setHostSets []string + resultHostSets []string + }{ + { + name: "Set host on empty set", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "empty"), + setHostSets: []string{hs[1].GetPublicId()}, + resultHostSets: []string{hs[1].GetPublicId()}, + }, + { + name: "Set host on populated set", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "populated", target.WithHostSets([]string{hs[0].GetPublicId()})), + setHostSets: []string{hs[1].GetPublicId()}, + resultHostSets: []string{hs[1].GetPublicId()}, + }, + { + name: "Set empty on populated set", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "another populated", target.WithHostSets([]string{hs[0].GetPublicId()})), + setHostSets: []string{}, + resultHostSets: nil, + }, + } + for _, tc := range setCases { + t.Run(tc.name, func(t *testing.T) { + req := &pbs.SetTargetHostSetsRequest{ + Id: tc.tar.GetPublicId(), + Version: tc.tar.GetVersion(), + HostSetIds: tc.setHostSets, + } + + got, err := s.SetTargetHostSets(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), req) + require.NoError(t, err, "Got error: %v", s) + assert.ElementsMatch(t, tc.resultHostSets, got.GetItem().GetHostSetIds()) + }) + } + + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "test name") + + failCases := []struct { + name string + req *pbs.SetTargetHostSetsRequest + errCode codes.Code + }{ + { + name: "Bad target Id", + req: &pbs.SetTargetHostSetsRequest{ + Id: "bad id", + Version: tar.GetVersion(), + HostSetIds: []string{hs[0].GetPublicId()}, + }, + errCode: codes.InvalidArgument, + }, + { + name: "Bad version", + req: &pbs.SetTargetHostSetsRequest{ + Id: tar.GetPublicId(), + Version: tar.GetVersion() + 3, + HostSetIds: []string{hs[0].GetPublicId()}, + }, + errCode: codes.Internal, + }, + } + for _, tc := range failCases { + t.Run(tc.name, func(t *testing.T) { + assert := assert.New(t) + _, gErr := s.SetTargetHostSets(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), tc.req) + assert.Equal(tc.errCode, status.Code(gErr), "SetTargetHostSets(%+v) got error %v, wanted %v", tc.req, gErr, tc.errCode) + }) + } +} + +func TestRemoveTargetHostSets(t *testing.T) { + conn, _ := db.TestSetup(t, "postgres") + wrapper := db.TestWrapper(t) + kms := kms.TestKms(t, conn, wrapper) + + _, proj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) + + iamRepoFn := func() (*iam.Repository, error) { + return iam.TestRepo(t, conn, wrapper), nil + } + rw := db.New(conn) + repoFn := func() (*target.Repository, error) { + return target.NewRepository(rw, rw, kms) + } + s, err := targets.NewService(repoFn, iamRepoFn) + require.NoError(t, err, "Error when getting new host set service.") + + hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] + hs := static.TestSets(t, conn, hc.GetPublicId(), 2) + + removeCases := []struct { + name string + tar *target.TcpTarget + removeHosts []string + resultHosts []string + wantErr bool + }{ + { + name: "Remove from empty", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "empty"), + removeHosts: []string{hs[1].GetPublicId()}, + wantErr: true, + }, + { + name: "Remove 1 of 2 sets", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "remove partial", target.WithHostSets([]string{hs[0].GetPublicId(), hs[1].GetPublicId()})), + removeHosts: []string{hs[1].GetPublicId()}, + resultHosts: []string{hs[0].GetPublicId()}, + }, + { + name: "Remove all hosts from set", + tar: target.TestTcpTarget(t, conn, proj.GetPublicId(), "remove all", target.WithHostSets([]string{hs[0].GetPublicId(), hs[1].GetPublicId()})), + removeHosts: []string{hs[0].GetPublicId(), hs[1].GetPublicId()}, + resultHosts: []string{}, + }, + } + + for _, tc := range removeCases { + t.Run(tc.name, func(t *testing.T) { + req := &pbs.RemoveTargetHostSetsRequest{ + Id: tc.tar.GetPublicId(), + Version: tc.tar.GetVersion(), + HostSetIds: tc.removeHosts, + } + + got, err := s.RemoveTargetHostSets(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), req) + if tc.wantErr { + assert.Error(t, err) + return + } + s, ok := status.FromError(err) + require.True(t, ok) + require.NoError(t, err, "Got error: %v", s) + + assert.ElementsMatch(t, tc.resultHosts, got.GetItem().GetHostSetIds()) + }) + } + + tar := target.TestTcpTarget(t, conn, proj.GetPublicId(), "testing") + + failCases := []struct { + name string + req *pbs.RemoveTargetHostSetsRequest + errCode codes.Code + }{ + { + name: "Bad version", + req: &pbs.RemoveTargetHostSetsRequest{ + Id: tar.GetPublicId(), + Version: tar.GetVersion() + 3, + HostSetIds: []string{hs[0].GetPublicId()}, + }, + errCode: codes.Internal, + }, + { + name: "Bad target Id", + req: &pbs.RemoveTargetHostSetsRequest{ + Id: "bad id", + Version: tar.GetVersion(), + HostSetIds: []string{hs[0].GetPublicId()}, + }, + errCode: codes.InvalidArgument, + }, + { + name: "empty sets", + req: &pbs.RemoveTargetHostSetsRequest{ + Id: "bad id", + Version: tar.GetVersion(), + HostSetIds: []string{}, + }, + errCode: codes.InvalidArgument, + }, + } + for _, tc := range failCases { + t.Run(tc.name, func(t *testing.T) { + assert := assert.New(t) + _, gErr := s.RemoveTargetHostSets(auth.DisabledAuthTestContext(auth.WithScopeId(proj.GetPublicId())), tc.req) + assert.Equal(tc.errCode, status.Code(gErr), "RemoveTargetHostSets(%+v) got error %v, wanted %v", tc.req, gErr, tc.errCode) + }) + } +} diff --git a/internal/target/repository.go b/internal/target/repository.go index fdbdd3c34..d264eacee 100644 --- a/internal/target/repository.go +++ b/internal/target/repository.go @@ -81,6 +81,9 @@ func (r *Repository) LookupTarget(ctx context.Context, publicId string, opt ...O }, ) if err != nil { + if errors.Is(err, db.ErrRecordNotFound) { + return nil, nil, nil + } return nil, nil, fmt.Errorf("lookup target: %w", err) } subType, err := target.targetSubType() diff --git a/internal/target/repository_tcp_target_test.go b/internal/target/repository_tcp_target_test.go index 26585c5d0..b71348652 100644 --- a/internal/target/repository_tcp_target_test.go +++ b/internal/target/repository_tcp_target_test.go @@ -49,7 +49,8 @@ func TestRepository_CreateTcpTarget(t *testing.T) { name: "valid-org", args: args{ target: func() *TcpTarget { - target, err := NewTcpTarget(proj.PublicId, "valid-org", + target, err := NewTcpTarget(proj.PublicId, + WithName("valid-org"), WithDescription("valid-org"), WithDefaultPort(uint32(22))) require.NoError(t, err) @@ -83,7 +84,7 @@ func TestRepository_CreateTcpTarget(t *testing.T) { name: "public-id-not-empty", args: args{ target: func() *TcpTarget { - target, err := NewTcpTarget(proj.PublicId, "valid-org", WithDescription("valid-org"), WithDefaultPort(uint32(22))) + target, err := NewTcpTarget(proj.PublicId, WithName("valid-org"), WithDescription("valid-org"), WithDefaultPort(uint32(22))) require.NoError(t, err) id, err := newTcpTargetId() require.NoError(t, err) diff --git a/internal/target/repository_test.go b/internal/target/repository_test.go index fab1901c2..c938ee222 100644 --- a/internal/target/repository_test.go +++ b/internal/target/repository_test.go @@ -276,9 +276,8 @@ func TestRepository_DeleteTarget(t *testing.T) { assert.NoError(err) assert.Equal(tt.wantRowsDeleted, deletedRows) foundGroup, _, err := repo.LookupTarget(context.Background(), tt.args.target.GetPublicId()) - assert.Error(err) + assert.NoError(err) assert.Nil(foundGroup) - assert.True(errors.Is(err, db.ErrRecordNotFound)) err = db.TestVerifyOplog(t, rw, tt.args.target.GetPublicId(), db.WithOperation(oplog.OpType_OP_TYPE_DELETE), db.WithCreateNotBefore(10*time.Second)) assert.NoError(err) diff --git a/internal/target/store/target.pb.go b/internal/target/store/target.pb.go index f824fbc9f..ad3240b9d 100644 --- a/internal/target/store/target.pb.go +++ b/internal/target/store/target.pb.go @@ -363,71 +363,70 @@ var file_controller_storage_target_store_v1_target_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x97, 0x03, 0x0a, 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x56, 0x69, 0x65, + 0x74, 0x6f, 0x22, 0xe5, 0x02, 0x0a, 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x56, 0x69, 0x65, 0x77, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xc2, 0xdd, 0x29, 0x0c, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x40, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x28, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x1e, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x28, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x32, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, + 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x50, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x5a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x99, 0x01, 0x0a, 0x0d, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0b, 0x68, 0x6f, 0x73, + 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x68, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, + 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xa3, 0x03, 0x0a, 0x09, 0x54, 0x63, 0x70, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, + 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xc2, 0xdd, 0x29, 0x0c, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1e, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x3c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4b, - 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x3c, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, - 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x50, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, 0x66, - 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x5a, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x0b, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x22, 0x99, 0x01, 0x0a, - 0x0d, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x12, 0x1b, - 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0b, 0x68, - 0x6f, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x68, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x74, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0b, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, - 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, - 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x82, 0x03, 0x0a, 0x09, 0x54, 0x63, 0x70, - 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, - 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49, 0x64, 0x12, 0x24, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xc2, 0xdd, - 0x29, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1e, 0xc2, 0xdd, 0x29, 0x1a, 0x0a, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x12, 0x4b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x3c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x46, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x50, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x0b, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x3b, 0x5a, - 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, - 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2f, 0x73, - 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6d, 0x70, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0c, 0x64, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x50, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x1f, + 0xc2, 0xdd, 0x29, 0x1b, 0x0a, 0x0b, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, + 0x74, 0x12, 0x0c, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x52, + 0x0b, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x3b, 0x5a, 0x39, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, + 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x2f, 0x73, 0x74, + 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/internal/target/target.go b/internal/target/target.go index ca4276d73..fae03b5bc 100644 --- a/internal/target/target.go +++ b/internal/target/target.go @@ -3,6 +3,7 @@ package target import ( "fmt" + "github.com/hashicorp/boundary/internal/db/timestamp" "github.com/hashicorp/boundary/internal/oplog" "github.com/hashicorp/boundary/internal/target/store" ) @@ -15,6 +16,8 @@ type Target interface { GetName() string GetDescription() string GetVersion() uint32 + GetCreateTime() *timestamp.Timestamp + GetUpdateTime() *timestamp.Timestamp oplog(op oplog.OpType) oplog.Metadata } diff --git a/internal/target/tcp_target.go b/internal/target/tcp_target.go index 078af055b..6a36c37f0 100644 --- a/internal/target/tcp_target.go +++ b/internal/target/tcp_target.go @@ -25,18 +25,15 @@ var _ oplog.ReplayableMessage = (*TcpTarget)(nil) // NewTcpTarget creates a new in memory tcp target. WithName, WithDescription and // WithDefaultPort options are supported -func NewTcpTarget(scopeId, name string, opt ...Option) (*TcpTarget, error) { +func NewTcpTarget(scopeId string, opt ...Option) (*TcpTarget, error) { opts := getOpts(opt...) if scopeId == "" { return nil, fmt.Errorf("new tcp target: missing scope id: %w", db.ErrInvalidParameter) } - if name == "" { - return nil, fmt.Errorf("new tcp target: missing name: %w", db.ErrInvalidParameter) - } t := &TcpTarget{ TcpTarget: &store.TcpTarget{ ScopeId: scopeId, - Name: name, + Name: opts.withName, Description: opts.withDescription, DefaultPort: opts.withDefaultPort, }, diff --git a/internal/target/tcp_target_test.go b/internal/target/tcp_target_test.go index a92495afd..97c930249 100644 --- a/internal/target/tcp_target_test.go +++ b/internal/target/tcp_target_test.go @@ -22,7 +22,6 @@ func TestTcpTarget_Create(t *testing.T) { _, prj := iam.TestScopes(t, iam.TestRepo(t, conn, wrapper)) type args struct { scopeId string - name string opt []Option } tests := []struct { @@ -44,7 +43,7 @@ func TestTcpTarget_Create(t *testing.T) { name: "valid-proj-scope", args: args{ scopeId: prj.PublicId, - name: "valid-proj-scope", + opt: []Option{WithName("valid-proj-scope")}, }, want: func() *TcpTarget { t := allocTcpTarget() @@ -58,7 +57,7 @@ func TestTcpTarget_Create(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { assert, require := assert.New(t), require.New(t) - got, err := NewTcpTarget(tt.args.scopeId, tt.args.name, tt.args.opt...) + got, err := NewTcpTarget(tt.args.scopeId, tt.args.opt...) if tt.wantErr { require.Error(err) assert.True(errors.Is(err, tt.wantIsErr)) diff --git a/internal/target/testing.go b/internal/target/testing.go index 2f814f5c7..c30411ee8 100644 --- a/internal/target/testing.go +++ b/internal/target/testing.go @@ -13,10 +13,11 @@ import ( func TestTcpTarget(t *testing.T, conn *gorm.DB, scopeId, name string, opt ...Option) *TcpTarget { t.Helper() + opt = append(opt, WithName(name)) opts := getOpts(opt...) require := require.New(t) rw := db.New(conn) - target, err := NewTcpTarget(scopeId, name, opt...) + target, err := NewTcpTarget(scopeId, opt...) require.NoError(err) id, err := newTcpTargetId() require.NoError(err) diff --git a/internal/types/action/action.go b/internal/types/action/action.go index 483d1f76c..f8fdfb320 100644 --- a/internal/types/action/action.go +++ b/internal/types/action/action.go @@ -30,6 +30,9 @@ const ( AddHosts Type = 21 SetHosts Type = 22 RemoveHosts Type = 23 + AddHostSets Type = 24 + SetHostSets Type = 25 + RemoveHostSets Type = 26 ) var Map = map[string]Type{ @@ -56,6 +59,9 @@ var Map = map[string]Type{ AddHosts.String(): AddHosts, SetHosts.String(): SetHosts, RemoveHosts.String(): RemoveHosts, + AddHostSets.String(): AddHostSets, + SetHostSets.String(): SetHostSets, + RemoveHostSets.String(): RemoveHostSets, } func (a Type) String() string { @@ -84,5 +90,8 @@ func (a Type) String() string { "add-hosts", "set-hosts", "remove-hosts", + "add-host-sets", + "set-host-sets", + "remove-host-sets", }[a] }