clientsv1connect

package
v0.0.0-...-c49e589 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UsersServiceName is the fully-qualified name of the UsersService service.
	UsersServiceName = "clients.v1.UsersService"
	// SessionsServiceName is the fully-qualified name of the SessionsService service.
	SessionsServiceName = "clients.v1.SessionsService"
	// TokensServiceName is the fully-qualified name of the TokensService service.
	TokensServiceName = "clients.v1.TokensService"
	// RolesServiceName is the fully-qualified name of the RolesService service.
	RolesServiceName = "clients.v1.RolesService"
	// ServiceAccessTokensServiceName is the fully-qualified name of the ServiceAccessTokensService
	// service.
	ServiceAccessTokensServiceName = "clients.v1.ServiceAccessTokensService"
)
View Source
const (
	// UsersServiceGetUserProcedure is the fully-qualified name of the UsersService's GetUser RPC.
	UsersServiceGetUserProcedure = "/clients.v1.UsersService/GetUser"
	// UsersServiceGetUsersProcedure is the fully-qualified name of the UsersService's GetUsers RPC.
	UsersServiceGetUsersProcedure = "/clients.v1.UsersService/GetUsers"
	// UsersServiceCreateUserProcedure is the fully-qualified name of the UsersService's CreateUser RPC.
	UsersServiceCreateUserProcedure = "/clients.v1.UsersService/CreateUser"
	// UsersServiceGetUserRolesProcedure is the fully-qualified name of the UsersService's GetUserRoles
	// RPC.
	UsersServiceGetUserRolesProcedure = "/clients.v1.UsersService/GetUserRoles"
	// UsersServiceGetUserMetadataProcedure is the fully-qualified name of the UsersService's
	// GetUserMetadata RPC.
	UsersServiceGetUserMetadataProcedure = "/clients.v1.UsersService/GetUserMetadata"
	// UsersServiceUpdateUserMetadataProcedure is the fully-qualified name of the UsersService's
	// UpdateUserMetadata RPC.
	UsersServiceUpdateUserMetadataProcedure = "/clients.v1.UsersService/UpdateUserMetadata"
	// SessionsServiceGetSessionProcedure is the fully-qualified name of the SessionsService's
	// GetSession RPC.
	SessionsServiceGetSessionProcedure = "/clients.v1.SessionsService/GetSession"
	// SessionsServiceSignOutSessionProcedure is the fully-qualified name of the SessionsService's
	// SignOutSession RPC.
	SessionsServiceSignOutSessionProcedure = "/clients.v1.SessionsService/SignOutSession"
	// TokensServiceIntrospectTokenProcedure is the fully-qualified name of the TokensService's
	// IntrospectToken RPC.
	TokensServiceIntrospectTokenProcedure = "/clients.v1.TokensService/IntrospectToken"
	// RolesServiceRegisterRoleResourcesProcedure is the fully-qualified name of the RolesService's
	// RegisterRoleResources RPC.
	RolesServiceRegisterRoleResourcesProcedure = "/clients.v1.RolesService/RegisterRoleResources"
	// ServiceAccessTokensServiceCreateServiceAccessTokenProcedure is the fully-qualified name of the
	// ServiceAccessTokensService's CreateServiceAccessToken RPC.
	ServiceAccessTokensServiceCreateServiceAccessTokenProcedure = "/clients.v1.ServiceAccessTokensService/CreateServiceAccessToken"
	// ServiceAccessTokensServiceListServiceAccessTokensProcedure is the fully-qualified name of the
	// ServiceAccessTokensService's ListServiceAccessTokens RPC.
	ServiceAccessTokensServiceListServiceAccessTokensProcedure = "/clients.v1.ServiceAccessTokensService/ListServiceAccessTokens"
	// ServiceAccessTokensServiceRevokeServiceAccessTokenProcedure is the fully-qualified name of the
	// ServiceAccessTokensService's RevokeServiceAccessToken RPC.
	ServiceAccessTokensServiceRevokeServiceAccessTokenProcedure = "/clients.v1.ServiceAccessTokensService/RevokeServiceAccessToken"
)

These constants are the fully-qualified names of the RPCs defined in this package. They're exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.

Note that these are different from the fully-qualified method names used by google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to reflection-formatted method names, remove the leading slash and convert the remaining slash to a period.

Variables

This section is empty.

Functions

func NewRolesServiceHandler

func NewRolesServiceHandler(svc RolesServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)

NewRolesServiceHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.

By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.

func NewServiceAccessTokensServiceHandler

func NewServiceAccessTokensServiceHandler(svc ServiceAccessTokensServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)

NewServiceAccessTokensServiceHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.

By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.

func NewSessionsServiceHandler

func NewSessionsServiceHandler(svc SessionsServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)

NewSessionsServiceHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.

By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.

func NewTokensServiceHandler

func NewTokensServiceHandler(svc TokensServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)

NewTokensServiceHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.

By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.

func NewUsersServiceHandler

func NewUsersServiceHandler(svc UsersServiceHandler, opts ...connect.HandlerOption) (string, http.Handler)

NewUsersServiceHandler builds an HTTP handler from the service implementation. It returns the path on which to mount the handler and the handler itself.

By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf and JSON codecs. They also support gzip compression.

Types

type RolesServiceClient

type RolesServiceClient interface {
	// RegisterRoleResources registers resources with SAMS.
	//
	// Only one client can register resources at a time for a particular resource type.
	// If another client is currently registering resources for the same resource type
	// this request will return an Aborted error.
	RegisterRoleResources(context.Context) *connect.ClientStreamForClient[v1.RegisterRoleResourcesRequest, v1.RegisterRoleResourcesResponse]
}

RolesServiceClient is a client for the clients.v1.RolesService service.

func NewRolesServiceClient

func NewRolesServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) RolesServiceClient

NewRolesServiceClient constructs a client for the clients.v1.RolesService service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.

The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).

type RolesServiceHandler

type RolesServiceHandler interface {
	// RegisterRoleResources registers resources with SAMS.
	//
	// Only one client can register resources at a time for a particular resource type.
	// If another client is currently registering resources for the same resource type
	// this request will return an Aborted error.
	RegisterRoleResources(context.Context, *connect.ClientStream[v1.RegisterRoleResourcesRequest]) (*connect.Response[v1.RegisterRoleResourcesResponse], error)
}

RolesServiceHandler is an implementation of the clients.v1.RolesService service.

type ServiceAccessTokensServiceClient

type ServiceAccessTokensServiceClient interface {
	// CreateServiceAccessToken creates a new service access token.
	// A client can only create service access tokens for services granted via scopes,
	// e.g. "sams::service_access_tokens.analytics::write" allows creating service access
	// tokens for the Sourcegraph Analytics service. Service access token can only have scopes that
	// belong to the same service, e.g. "analytics::analytics::read" when the service is
	// "analytics".
	CreateServiceAccessToken(context.Context, *connect.Request[v1.CreateServiceAccessTokenRequest]) (*connect.Response[v1.CreateServiceAccessTokenResponse], error)
	// ListServiceAccessTokens returns a list of service access tokens in reverse chronological
	// order by creation time. A client can only list service access tokens for services granted
	// via scopes, e.g. "sams::service_access_tokens.analytics::read" allows listing service
	// access tokens for the Sourcegraph Analytics service.
	ListServiceAccessTokens(context.Context, *connect.Request[v1.ListServiceAccessTokensRequest]) (*connect.Response[v1.ListServiceAccessTokensResponse], error)
	// RevokeServiceAccessToken revokes the specified service access token. A client can only revoke
	// service access tokens for services granted via scopes, e.g.
	// "sams::service_access_tokens.analytics::delete" allows revoking service access tokens for
	// the Sourcegraph Analytics service.
	RevokeServiceAccessToken(context.Context, *connect.Request[v1.RevokeServiceAccessTokenRequest]) (*connect.Response[v1.RevokeServiceAccessTokenResponse], error)
}

ServiceAccessTokensServiceClient is a client for the clients.v1.ServiceAccessTokensService service.

func NewServiceAccessTokensServiceClient

func NewServiceAccessTokensServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) ServiceAccessTokensServiceClient

NewServiceAccessTokensServiceClient constructs a client for the clients.v1.ServiceAccessTokensService service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.

The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).

type ServiceAccessTokensServiceHandler

type ServiceAccessTokensServiceHandler interface {
	// CreateServiceAccessToken creates a new service access token.
	// A client can only create service access tokens for services granted via scopes,
	// e.g. "sams::service_access_tokens.analytics::write" allows creating service access
	// tokens for the Sourcegraph Analytics service. Service access token can only have scopes that
	// belong to the same service, e.g. "analytics::analytics::read" when the service is
	// "analytics".
	CreateServiceAccessToken(context.Context, *connect.Request[v1.CreateServiceAccessTokenRequest]) (*connect.Response[v1.CreateServiceAccessTokenResponse], error)
	// ListServiceAccessTokens returns a list of service access tokens in reverse chronological
	// order by creation time. A client can only list service access tokens for services granted
	// via scopes, e.g. "sams::service_access_tokens.analytics::read" allows listing service
	// access tokens for the Sourcegraph Analytics service.
	ListServiceAccessTokens(context.Context, *connect.Request[v1.ListServiceAccessTokensRequest]) (*connect.Response[v1.ListServiceAccessTokensResponse], error)
	// RevokeServiceAccessToken revokes the specified service access token. A client can only revoke
	// service access tokens for services granted via scopes, e.g.
	// "sams::service_access_tokens.analytics::delete" allows revoking service access tokens for
	// the Sourcegraph Analytics service.
	RevokeServiceAccessToken(context.Context, *connect.Request[v1.RevokeServiceAccessTokenRequest]) (*connect.Response[v1.RevokeServiceAccessTokenResponse], error)
}

ServiceAccessTokensServiceHandler is an implementation of the clients.v1.ServiceAccessTokensService service.

type SessionsServiceClient

type SessionsServiceClient interface {
	// GetSession returns the SAMS session with the given ID. It returns
	// connect.CodeNotFound if no such session exists. The session's `User` field is
	// populated if the session is authenticated by a user.
	//
	// Required scope: sams::session::read
	GetSession(context.Context, *connect.Request[v1.GetSessionRequest]) (*connect.Response[v1.GetSessionResponse], error)
	// SignOutSession revokes the authenticated state of the session with the given
	// ID for the given user. It does not return error if the session does not exist
	// or is not authenticated. It returns clientsv1.ErrorRecordMismatch in the
	// error detail if the session is authenticated by a different user than the
	// given user.
	//
	// Required scope: sams::session::write
	SignOutSession(context.Context, *connect.Request[v1.SignOutSessionRequest]) (*connect.Response[v1.SignOutSessionResponse], error)
}

SessionsServiceClient is a client for the clients.v1.SessionsService service.

func NewSessionsServiceClient

func NewSessionsServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SessionsServiceClient

NewSessionsServiceClient constructs a client for the clients.v1.SessionsService service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.

The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).

type SessionsServiceHandler

type SessionsServiceHandler interface {
	// GetSession returns the SAMS session with the given ID. It returns
	// connect.CodeNotFound if no such session exists. The session's `User` field is
	// populated if the session is authenticated by a user.
	//
	// Required scope: sams::session::read
	GetSession(context.Context, *connect.Request[v1.GetSessionRequest]) (*connect.Response[v1.GetSessionResponse], error)
	// SignOutSession revokes the authenticated state of the session with the given
	// ID for the given user. It does not return error if the session does not exist
	// or is not authenticated. It returns clientsv1.ErrorRecordMismatch in the
	// error detail if the session is authenticated by a different user than the
	// given user.
	//
	// Required scope: sams::session::write
	SignOutSession(context.Context, *connect.Request[v1.SignOutSessionRequest]) (*connect.Response[v1.SignOutSessionResponse], error)
}

SessionsServiceHandler is an implementation of the clients.v1.SessionsService service.

type TokensServiceClient

type TokensServiceClient interface {
	// IntrospectToken takes a SAMS access token and returns relevant metadata.
	//
	// 🚨SECURITY: SAMS will return a successful result if the token is valid, but
	// is no longer active. It is critical that the caller not honor tokens where
	// `.Active == false`.
	IntrospectToken(context.Context, *connect.Request[v1.IntrospectTokenRequest]) (*connect.Response[v1.IntrospectTokenResponse], error)
}

TokensServiceClient is a client for the clients.v1.TokensService service.

func NewTokensServiceClient

func NewTokensServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) TokensServiceClient

NewTokensServiceClient constructs a client for the clients.v1.TokensService service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.

The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).

type TokensServiceHandler

type TokensServiceHandler interface {
	// IntrospectToken takes a SAMS access token and returns relevant metadata.
	//
	// 🚨SECURITY: SAMS will return a successful result if the token is valid, but
	// is no longer active. It is critical that the caller not honor tokens where
	// `.Active == false`.
	IntrospectToken(context.Context, *connect.Request[v1.IntrospectTokenRequest]) (*connect.Response[v1.IntrospectTokenResponse], error)
}

TokensServiceHandler is an implementation of the clients.v1.TokensService service.

type UnimplementedRolesServiceHandler

type UnimplementedRolesServiceHandler struct{}

UnimplementedRolesServiceHandler returns CodeUnimplemented from all methods.

type UnimplementedServiceAccessTokensServiceHandler

type UnimplementedServiceAccessTokensServiceHandler struct{}

UnimplementedServiceAccessTokensServiceHandler returns CodeUnimplemented from all methods.

type UnimplementedSessionsServiceHandler

type UnimplementedSessionsServiceHandler struct{}

UnimplementedSessionsServiceHandler returns CodeUnimplemented from all methods.

type UnimplementedTokensServiceHandler

type UnimplementedTokensServiceHandler struct{}

UnimplementedTokensServiceHandler returns CodeUnimplemented from all methods.

type UnimplementedUsersServiceHandler

type UnimplementedUsersServiceHandler struct{}

UnimplementedUsersServiceHandler returns CodeUnimplemented from all methods.

type UsersServiceClient

type UsersServiceClient interface {
	// GetUser returns the SAMS user with the given query. It returns connect.CodeNotFound
	// if no such user exists.
	//
	// Required scope: profile
	GetUser(context.Context, *connect.Request[v1.GetUserRequest]) (*connect.Response[v1.GetUserResponse], error)
	// GetUsers returns the list of SAMS users matching the provided IDs.
	//
	// NOTE: It silently ignores any invalid user IDs, i.e. the length of the return
	// slice may be less than the length of the input slice.
	//
	// Required scopes: profile
	GetUsers(context.Context, *connect.Request[v1.GetUsersRequest]) (*connect.Response[v1.GetUsersResponse], error)
	// CreateUser creates a new SAMS user with the given email.
	// Required scopes: sams::user::write
	CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.CreateUserResponse], error)
	// GetUserRoles returns all roles that have been assigned to the SAMS user
	// with the given ID and scoped by the service.
	//
	// Required scopes: sams::user.roles::read
	GetUserRoles(context.Context, *connect.Request[v1.GetUserRolesRequest]) (*connect.Response[v1.GetUserRolesResponse], error)
	// GetUserMetadata retrieves metadata for a SAMS user.
	//
	// Required scopes: 'sams::user.metadata::read' or metadata-namespace-specific
	// variant scope, such as 'sams::user.metadata.dotcom::read'
	GetUserMetadata(context.Context, *connect.Request[v1.GetUserMetadataRequest]) (*connect.Response[v1.GetUserMetadataResponse], error)
	// UpdateUserMetadata updates the metadata of a SAMS user.
	//
	// Required scopes: 'sams::user.metadata::write' or metadata-namespace-specific
	// variant scope, such as 'sams::user.metadata.dotcom::write'
	UpdateUserMetadata(context.Context, *connect.Request[v1.UpdateUserMetadataRequest]) (*connect.Response[v1.UpdateUserMetadataResponse], error)
}

UsersServiceClient is a client for the clients.v1.UsersService service.

func NewUsersServiceClient

func NewUsersServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) UsersServiceClient

NewUsersServiceClient constructs a client for the clients.v1.UsersService service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or connect.WithGRPCWeb() options.

The URL supplied here should be the base URL for the Connect or gRPC server (for example, http://api.acme.com or https://acme.com/grpc).

type UsersServiceHandler

type UsersServiceHandler interface {
	// GetUser returns the SAMS user with the given query. It returns connect.CodeNotFound
	// if no such user exists.
	//
	// Required scope: profile
	GetUser(context.Context, *connect.Request[v1.GetUserRequest]) (*connect.Response[v1.GetUserResponse], error)
	// GetUsers returns the list of SAMS users matching the provided IDs.
	//
	// NOTE: It silently ignores any invalid user IDs, i.e. the length of the return
	// slice may be less than the length of the input slice.
	//
	// Required scopes: profile
	GetUsers(context.Context, *connect.Request[v1.GetUsersRequest]) (*connect.Response[v1.GetUsersResponse], error)
	// CreateUser creates a new SAMS user with the given email.
	// Required scopes: sams::user::write
	CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.CreateUserResponse], error)
	// GetUserRoles returns all roles that have been assigned to the SAMS user
	// with the given ID and scoped by the service.
	//
	// Required scopes: sams::user.roles::read
	GetUserRoles(context.Context, *connect.Request[v1.GetUserRolesRequest]) (*connect.Response[v1.GetUserRolesResponse], error)
	// GetUserMetadata retrieves metadata for a SAMS user.
	//
	// Required scopes: 'sams::user.metadata::read' or metadata-namespace-specific
	// variant scope, such as 'sams::user.metadata.dotcom::read'
	GetUserMetadata(context.Context, *connect.Request[v1.GetUserMetadataRequest]) (*connect.Response[v1.GetUserMetadataResponse], error)
	// UpdateUserMetadata updates the metadata of a SAMS user.
	//
	// Required scopes: 'sams::user.metadata::write' or metadata-namespace-specific
	// variant scope, such as 'sams::user.metadata.dotcom::write'
	UpdateUserMetadata(context.Context, *connect.Request[v1.UpdateUserMetadataRequest]) (*connect.Response[v1.UpdateUserMetadataResponse], error)
}

UsersServiceHandler is an implementation of the clients.v1.UsersService service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL