sma

package
v0.0.0-...-3fa0e8d Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package sma is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	Posts_CreatePost_FullMethodName = "/sma.Posts/CreatePost"
	Posts_UpdatePost_FullMethodName = "/sma.Posts/UpdatePost"
	Posts_ShowPost_FullMethodName   = "/sma.Posts/ShowPost"
	Posts_ListPosts_FullMethodName  = "/sma.Posts/ListPosts"
	Posts_DeletePost_FullMethodName = "/sma.Posts/DeletePost"
)

Variables

View Source
var (
	PostStatus_name = map[int32]string{
		0: "POST_STATUS_UNSPECIFIED",
		1: "POST_STATUS_DRAFT",
		2: "POST_STATUS_SCHEDULED",
		3: "POST_STATUS_ARCHIVED",
		4: "POST_STATUS_ACTIVE",
	}
	PostStatus_value = map[string]int32{
		"POST_STATUS_UNSPECIFIED": 0,
		"POST_STATUS_DRAFT":       1,
		"POST_STATUS_SCHEDULED":   2,
		"POST_STATUS_ARCHIVED":    3,
		"POST_STATUS_ACTIVE":      4,
	}
)

Enum value maps for PostStatus.

View Source
var (
	Filters_name = map[int32]string{
		0: "FILTER_UNESPECIFIED",
		1: "FILTER_DRAFT",
		2: "FILTER_SCHEDULED",
		3: "FILTER_ARCHIVED",
		4: "FILTER_ACTIVE",
	}
	Filters_value = map[string]int32{
		"FILTER_UNESPECIFIED": 0,
		"FILTER_DRAFT":        1,
		"FILTER_SCHEDULED":    2,
		"FILTER_ARCHIVED":     3,
		"FILTER_ACTIVE":       4,
	}
)

Enum value maps for Filters.

View Source
var File_posts_proto protoreflect.FileDescriptor
View Source
var Posts_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "sma.Posts",
	HandlerType: (*PostsServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreatePost",
			Handler:    _Posts_CreatePost_Handler,
		},
		{
			MethodName: "UpdatePost",
			Handler:    _Posts_UpdatePost_Handler,
		},
		{
			MethodName: "ShowPost",
			Handler:    _Posts_ShowPost_Handler,
		},
		{
			MethodName: "ListPosts",
			Handler:    _Posts_ListPosts_Handler,
		},
		{
			MethodName: "DeletePost",
			Handler:    _Posts_DeletePost_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "posts.proto",
}

Posts_ServiceDesc is the grpc.ServiceDesc for Posts service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterPostsHandler

func RegisterPostsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterPostsHandler registers the http handlers for service Posts to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterPostsHandlerClient

func RegisterPostsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PostsClient) error

RegisterPostsHandlerClient registers the http handlers for service Posts to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PostsClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PostsClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "PostsClient" to call the correct interceptors.

func RegisterPostsHandlerFromEndpoint

func RegisterPostsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterPostsHandlerFromEndpoint is same as RegisterPostsHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterPostsHandlerServer

func RegisterPostsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PostsServer) error

RegisterPostsHandlerServer registers the http handlers for service Posts to "mux". UnaryRPC :call PostsServer 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 to stop working. Consider using RegisterPostsHandlerFromEndpoint instead.

func RegisterPostsServer

func RegisterPostsServer(s grpc.ServiceRegistrar, srv PostsServer)

Types

type CreatePostReq

type CreatePostReq struct {

	// The title for the Post
	Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	// The description for the Post
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// The id of the user who created the Post
	UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// The collection of the Posts's media files
	MediaIds []string `protobuf:"bytes,4,rep,name=media_ids,json=mediaIds,proto3" json:"media_ids,omitempty"`
	// The schedule date for the post
	ScheduledAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=scheduled_at,json=scheduledAt,proto3" json:"scheduled_at,omitempty"`
	// contains filtered or unexported fields
}

CreatePostReq

The request message to create a post

func (*CreatePostReq) Descriptor deprecated

func (*CreatePostReq) Descriptor() ([]byte, []int)

Deprecated: Use CreatePostReq.ProtoReflect.Descriptor instead.

func (*CreatePostReq) GetDescription

func (x *CreatePostReq) GetDescription() string

func (*CreatePostReq) GetMediaIds

func (x *CreatePostReq) GetMediaIds() []string

func (*CreatePostReq) GetScheduledAt

func (x *CreatePostReq) GetScheduledAt() *timestamppb.Timestamp

func (*CreatePostReq) GetTitle

func (x *CreatePostReq) GetTitle() string

func (*CreatePostReq) GetUserId

func (x *CreatePostReq) GetUserId() string

func (*CreatePostReq) ProtoMessage

func (*CreatePostReq) ProtoMessage()

func (*CreatePostReq) ProtoReflect

func (x *CreatePostReq) ProtoReflect() protoreflect.Message

func (*CreatePostReq) Reset

func (x *CreatePostReq) Reset()

func (*CreatePostReq) String

func (x *CreatePostReq) String() string

type EmptyResp

type EmptyResp struct {
	// contains filtered or unexported fields
}

EmptyResp

An empty response

func (*EmptyResp) Descriptor deprecated

func (*EmptyResp) Descriptor() ([]byte, []int)

Deprecated: Use EmptyResp.ProtoReflect.Descriptor instead.

func (*EmptyResp) ProtoMessage

func (*EmptyResp) ProtoMessage()

func (*EmptyResp) ProtoReflect

func (x *EmptyResp) ProtoReflect() protoreflect.Message

func (*EmptyResp) Reset

func (x *EmptyResp) Reset()

func (*EmptyResp) String

func (x *EmptyResp) String() string

type Filters

type Filters int32
const (
	Filters_FILTER_UNESPECIFIED Filters = 0
	Filters_FILTER_DRAFT        Filters = 1
	Filters_FILTER_SCHEDULED    Filters = 2
	Filters_FILTER_ARCHIVED     Filters = 3
	Filters_FILTER_ACTIVE       Filters = 4
)

func (Filters) Descriptor

func (Filters) Descriptor() protoreflect.EnumDescriptor

func (Filters) Enum

func (x Filters) Enum() *Filters

func (Filters) EnumDescriptor deprecated

func (Filters) EnumDescriptor() ([]byte, []int)

Deprecated: Use Filters.Descriptor instead.

func (Filters) Number

func (x Filters) Number() protoreflect.EnumNumber

func (Filters) String

func (x Filters) String() string

func (Filters) Type

func (Filters) Type() protoreflect.EnumType

type ListPostsReq

type ListPostsReq struct {

	// The id for the user
	UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// Search query string
	S string `protobuf:"bytes,2,opt,name=s,proto3" json:"s,omitempty"`
	// Requested page
	Page string `protobuf:"bytes,3,opt,name=page,proto3" json:"page,omitempty"`
	// Requested number of items per page
	// Default: 20
	// Max: 50
	PerPage string `protobuf:"bytes,4,opt,name=per_page,json=perPage,proto3" json:"per_page,omitempty"`
	// Filtered collection by status
	Filter Filters `protobuf:"varint,5,opt,name=filter,proto3,enum=sma.Filters" json:"filter,omitempty"`
	// contains filtered or unexported fields
}

ListPostsReq

The request message to list the collection of posts for a given user

func (*ListPostsReq) Descriptor deprecated

func (*ListPostsReq) Descriptor() ([]byte, []int)

Deprecated: Use ListPostsReq.ProtoReflect.Descriptor instead.

func (*ListPostsReq) GetFilter

func (x *ListPostsReq) GetFilter() Filters

func (*ListPostsReq) GetPage

func (x *ListPostsReq) GetPage() string

func (*ListPostsReq) GetPerPage

func (x *ListPostsReq) GetPerPage() string

func (*ListPostsReq) GetS

func (x *ListPostsReq) GetS() string

func (*ListPostsReq) GetUserId

func (x *ListPostsReq) GetUserId() string

func (*ListPostsReq) ProtoMessage

func (*ListPostsReq) ProtoMessage()

func (*ListPostsReq) ProtoReflect

func (x *ListPostsReq) ProtoReflect() protoreflect.Message

func (*ListPostsReq) Reset

func (x *ListPostsReq) Reset()

func (*ListPostsReq) String

func (x *ListPostsReq) String() string

type ListPostsResp

type ListPostsResp struct {

	// The collection of posts
	Posts []*Post `protobuf:"bytes,1,rep,name=posts,proto3" json:"posts,omitempty"`
	// Page info
	PageInfo *PageInfo `protobuf:"bytes,2,opt,name=page_info,json=pageInfo,proto3" json:"page_info,omitempty"`
	// contains filtered or unexported fields
}

ListPostsResp

The response message to list the collection of posts for a given user

func (*ListPostsResp) Descriptor deprecated

func (*ListPostsResp) Descriptor() ([]byte, []int)

Deprecated: Use ListPostsResp.ProtoReflect.Descriptor instead.

func (*ListPostsResp) GetPageInfo

func (x *ListPostsResp) GetPageInfo() *PageInfo

func (*ListPostsResp) GetPosts

func (x *ListPostsResp) GetPosts() []*Post

func (*ListPostsResp) ProtoMessage

func (*ListPostsResp) ProtoMessage()

func (*ListPostsResp) ProtoReflect

func (x *ListPostsResp) ProtoReflect() protoreflect.Message

func (*ListPostsResp) Reset

func (x *ListPostsResp) Reset()

func (*ListPostsResp) String

func (x *ListPostsResp) String() string

type PageInfo

type PageInfo struct {

	// The current page
	Page uint64 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"`
	// The page size
	PageSize uint64 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	// The total items
	TotalItems uint64 `protobuf:"varint,3,opt,name=total_items,json=totalItems,proto3" json:"total_items,omitempty"`
	// The total pages
	TotalPages uint64 `protobuf:"varint,4,opt,name=total_pages,json=totalPages,proto3" json:"total_pages,omitempty"`
	// contains filtered or unexported fields
}

func (*PageInfo) Descriptor deprecated

func (*PageInfo) Descriptor() ([]byte, []int)

Deprecated: Use PageInfo.ProtoReflect.Descriptor instead.

func (*PageInfo) GetPage

func (x *PageInfo) GetPage() uint64

func (*PageInfo) GetPageSize

func (x *PageInfo) GetPageSize() uint64

func (*PageInfo) GetTotalItems

func (x *PageInfo) GetTotalItems() uint64

func (*PageInfo) GetTotalPages

func (x *PageInfo) GetTotalPages() uint64

func (*PageInfo) ProtoMessage

func (*PageInfo) ProtoMessage()

func (*PageInfo) ProtoReflect

func (x *PageInfo) ProtoReflect() protoreflect.Message

func (*PageInfo) Reset

func (x *PageInfo) Reset()

func (*PageInfo) String

func (x *PageInfo) String() string

type Post

type Post struct {

	// The id for the Post
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The title for the Post
	Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
	// The description for the Post
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	// The is of the user who created the Post
	UserId string `protobuf:"bytes,4,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	// The current status of the Post
	Status PostStatus `protobuf:"varint,5,opt,name=status,proto3,enum=sma.PostStatus" json:"status,omitempty"`
	// The date when the Post was created
	CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	// The date when the Post was updated
	UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

Post

The message that represents a post

func (*Post) Descriptor deprecated

func (*Post) Descriptor() ([]byte, []int)

Deprecated: Use Post.ProtoReflect.Descriptor instead.

func (*Post) GetCreatedAt

func (x *Post) GetCreatedAt() *timestamppb.Timestamp

func (*Post) GetDescription

func (x *Post) GetDescription() string

func (*Post) GetId

func (x *Post) GetId() string

func (*Post) GetStatus

func (x *Post) GetStatus() PostStatus

func (*Post) GetTitle

func (x *Post) GetTitle() string

func (*Post) GetUpdatedAt

func (x *Post) GetUpdatedAt() *timestamppb.Timestamp

func (*Post) GetUserId

func (x *Post) GetUserId() string

func (*Post) ProtoMessage

func (*Post) ProtoMessage()

func (*Post) ProtoReflect

func (x *Post) ProtoReflect() protoreflect.Message

func (*Post) Reset

func (x *Post) Reset()

func (*Post) String

func (x *Post) String() string

type PostIdReq

type PostIdReq struct {

	// The id for the post
	PostId string `protobuf:"bytes,1,opt,name=post_id,json=postId,proto3" json:"post_id,omitempty"`
	// contains filtered or unexported fields
}

PostIdReq

The request message to show a post

func (*PostIdReq) Descriptor deprecated

func (*PostIdReq) Descriptor() ([]byte, []int)

Deprecated: Use PostIdReq.ProtoReflect.Descriptor instead.

func (*PostIdReq) GetPostId

func (x *PostIdReq) GetPostId() string

func (*PostIdReq) ProtoMessage

func (*PostIdReq) ProtoMessage()

func (*PostIdReq) ProtoReflect

func (x *PostIdReq) ProtoReflect() protoreflect.Message

func (*PostIdReq) Reset

func (x *PostIdReq) Reset()

func (*PostIdReq) String

func (x *PostIdReq) String() string

type PostStatus

type PostStatus int32
const (
	PostStatus_POST_STATUS_UNSPECIFIED PostStatus = 0
	PostStatus_POST_STATUS_DRAFT       PostStatus = 1
	PostStatus_POST_STATUS_SCHEDULED   PostStatus = 2
	PostStatus_POST_STATUS_ARCHIVED    PostStatus = 3
	PostStatus_POST_STATUS_ACTIVE      PostStatus = 4
)

func (PostStatus) Descriptor

func (PostStatus) Descriptor() protoreflect.EnumDescriptor

func (PostStatus) Enum

func (x PostStatus) Enum() *PostStatus

func (PostStatus) EnumDescriptor deprecated

func (PostStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use PostStatus.Descriptor instead.

func (PostStatus) Number

func (x PostStatus) Number() protoreflect.EnumNumber

func (PostStatus) String

func (x PostStatus) String() string

func (PostStatus) Type

type PostsClient

type PostsClient interface {
	// Create Post
	//
	// Create a new post
	CreatePost(ctx context.Context, in *CreatePostReq, opts ...grpc.CallOption) (*Post, error)
	// Update Post
	//
	// Updates a specific post
	UpdatePost(ctx context.Context, in *UpdatePostReq, opts ...grpc.CallOption) (*Post, error)
	// Show Post
	//
	// Show a specific post
	ShowPost(ctx context.Context, in *PostIdReq, opts ...grpc.CallOption) (*Post, error)
	// ListPosts
	//
	// Returns a collection of posts for a given user
	ListPosts(ctx context.Context, in *ListPostsReq, opts ...grpc.CallOption) (*ListPostsResp, error)
	// DeletePost
	//
	// Deletes a specific post
	DeletePost(ctx context.Context, in *PostIdReq, opts ...grpc.CallOption) (*EmptyResp, error)
}

PostsClient is the client API for Posts service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewPostsClient

func NewPostsClient(cc grpc.ClientConnInterface) PostsClient

type PostsServer

type PostsServer interface {
	// Create Post
	//
	// Create a new post
	CreatePost(context.Context, *CreatePostReq) (*Post, error)
	// Update Post
	//
	// Updates a specific post
	UpdatePost(context.Context, *UpdatePostReq) (*Post, error)
	// Show Post
	//
	// Show a specific post
	ShowPost(context.Context, *PostIdReq) (*Post, error)
	// ListPosts
	//
	// Returns a collection of posts for a given user
	ListPosts(context.Context, *ListPostsReq) (*ListPostsResp, error)
	// DeletePost
	//
	// Deletes a specific post
	DeletePost(context.Context, *PostIdReq) (*EmptyResp, error)
	// contains filtered or unexported methods
}

PostsServer is the server API for Posts service. All implementations must embed UnimplementedPostsServer for forward compatibility

type UnimplementedPostsServer

type UnimplementedPostsServer struct{}

UnimplementedPostsServer must be embedded to have forward compatible implementations.

func (UnimplementedPostsServer) CreatePost

func (UnimplementedPostsServer) DeletePost

func (UnimplementedPostsServer) ListPosts

func (UnimplementedPostsServer) ShowPost

func (UnimplementedPostsServer) UpdatePost

type UnsafePostsServer

type UnsafePostsServer interface {
	// contains filtered or unexported methods
}

UnsafePostsServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to PostsServer will result in compilation errors.

type UpdatePost

type UpdatePost struct {

	// The title for the post
	Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	// The description for the post
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// The collection of the Posts's media files
	MediaIds []string `protobuf:"bytes,3,rep,name=media_ids,json=mediaIds,proto3" json:"media_ids,omitempty"`
	// The schedule date for the post
	ScheduledAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=scheduled_at,json=scheduledAt,proto3" json:"scheduled_at,omitempty"`
	// contains filtered or unexported fields
}

UpdatePost

The message that keeps track of the permitted attributes to be updated for a post

func (*UpdatePost) Descriptor deprecated

func (*UpdatePost) Descriptor() ([]byte, []int)

Deprecated: Use UpdatePost.ProtoReflect.Descriptor instead.

func (*UpdatePost) GetDescription

func (x *UpdatePost) GetDescription() string

func (*UpdatePost) GetMediaIds

func (x *UpdatePost) GetMediaIds() []string

func (*UpdatePost) GetScheduledAt

func (x *UpdatePost) GetScheduledAt() *timestamppb.Timestamp

func (*UpdatePost) GetTitle

func (x *UpdatePost) GetTitle() string

func (*UpdatePost) ProtoMessage

func (*UpdatePost) ProtoMessage()

func (*UpdatePost) ProtoReflect

func (x *UpdatePost) ProtoReflect() protoreflect.Message

func (*UpdatePost) Reset

func (x *UpdatePost) Reset()

func (*UpdatePost) String

func (x *UpdatePost) String() string

type UpdatePostReq

type UpdatePostReq struct {

	// Field mask for a post
	UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,1,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
	// The id for the post
	PostId string `protobuf:"bytes,2,opt,name=post_id,json=postId,proto3" json:"post_id,omitempty"`
	// The updatable fields that are allowed to be updated
	Post *UpdatePost `protobuf:"bytes,3,opt,name=post,proto3" json:"post,omitempty"`
	// contains filtered or unexported fields
}

UpdatePostReq

The request message to update a post

func (*UpdatePostReq) Descriptor deprecated

func (*UpdatePostReq) Descriptor() ([]byte, []int)

Deprecated: Use UpdatePostReq.ProtoReflect.Descriptor instead.

func (*UpdatePostReq) GetPost

func (x *UpdatePostReq) GetPost() *UpdatePost

func (*UpdatePostReq) GetPostId

func (x *UpdatePostReq) GetPostId() string

func (*UpdatePostReq) GetUpdateMask

func (x *UpdatePostReq) GetUpdateMask() *fieldmaskpb.FieldMask

func (*UpdatePostReq) ProtoMessage

func (*UpdatePostReq) ProtoMessage()

func (*UpdatePostReq) ProtoReflect

func (x *UpdatePostReq) ProtoReflect() protoreflect.Message

func (*UpdatePostReq) Reset

func (x *UpdatePostReq) Reset()

func (*UpdatePostReq) String

func (x *UpdatePostReq) String() string

Jump to

Keyboard shortcuts

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