add google search (#242)

* add google search

* fix git ignore

* Charge 1c for search queries
This commit is contained in:
Asim Aslam
2021-10-25 12:16:41 +01:00
committed by GitHub
parent 30673f9837
commit 0bfe1e3c19
13 changed files with 656 additions and 0 deletions

332
google/proto/google.pb.go Normal file
View File

@@ -0,0 +1,332 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.15.6
// source: proto/google.proto
package google
import (
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)
)
type SearchResult struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// id of the result
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// kind of result; "search"
Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"`
// title of the result
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
// the result snippet
Snippet string `protobuf:"bytes,4,opt,name=snippet,proto3" json:"snippet,omitempty"`
// the full url for the result
Url string `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"`
// abridged version of this search results URL, e.g. www.exampe.com
DisplayUrl string `protobuf:"bytes,6,opt,name=display_url,json=displayUrl,proto3" json:"display_url,omitempty"`
}
func (x *SearchResult) Reset() {
*x = SearchResult{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_google_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SearchResult) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SearchResult) ProtoMessage() {}
func (x *SearchResult) ProtoReflect() protoreflect.Message {
mi := &file_proto_google_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 SearchResult.ProtoReflect.Descriptor instead.
func (*SearchResult) Descriptor() ([]byte, []int) {
return file_proto_google_proto_rawDescGZIP(), []int{0}
}
func (x *SearchResult) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *SearchResult) GetKind() string {
if x != nil {
return x.Kind
}
return ""
}
func (x *SearchResult) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (x *SearchResult) GetSnippet() string {
if x != nil {
return x.Snippet
}
return ""
}
func (x *SearchResult) GetUrl() string {
if x != nil {
return x.Url
}
return ""
}
func (x *SearchResult) GetDisplayUrl() string {
if x != nil {
return x.DisplayUrl
}
return ""
}
// Search for videos on Google
type SearchRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Query to search for
Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"`
}
func (x *SearchRequest) Reset() {
*x = SearchRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_google_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SearchRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SearchRequest) ProtoMessage() {}
func (x *SearchRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_google_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 SearchRequest.ProtoReflect.Descriptor instead.
func (*SearchRequest) Descriptor() ([]byte, []int) {
return file_proto_google_proto_rawDescGZIP(), []int{1}
}
func (x *SearchRequest) GetQuery() string {
if x != nil {
return x.Query
}
return ""
}
type SearchResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// List of results for the query
Results []*SearchResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
}
func (x *SearchResponse) Reset() {
*x = SearchResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_google_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SearchResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SearchResponse) ProtoMessage() {}
func (x *SearchResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_google_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 SearchResponse.ProtoReflect.Descriptor instead.
func (*SearchResponse) Descriptor() ([]byte, []int) {
return file_proto_google_proto_rawDescGZIP(), []int{2}
}
func (x *SearchResponse) GetResults() []*SearchResult {
if x != nil {
return x.Results
}
return nil
}
var File_proto_google_proto protoreflect.FileDescriptor
var file_proto_google_proto_rawDesc = []byte{
0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x22, 0x95, 0x01, 0x0a,
0x0c, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e,
0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6e, 0x69, 0x70, 0x70,
0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x6e, 0x69, 0x70, 0x70, 0x65,
0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x75, 0x72, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x75,
0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61,
0x79, 0x55, 0x72, 0x6c, 0x22, 0x25, 0x0a, 0x0d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x40, 0x0a, 0x0e, 0x53,
0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a,
0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65,
0x73, 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x32, 0x43, 0x0a,
0x06, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x12, 0x39, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63,
0x68, 0x12, 0x15, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63,
0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_google_proto_rawDescOnce sync.Once
file_proto_google_proto_rawDescData = file_proto_google_proto_rawDesc
)
func file_proto_google_proto_rawDescGZIP() []byte {
file_proto_google_proto_rawDescOnce.Do(func() {
file_proto_google_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_google_proto_rawDescData)
})
return file_proto_google_proto_rawDescData
}
var file_proto_google_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_proto_google_proto_goTypes = []interface{}{
(*SearchResult)(nil), // 0: google.SearchResult
(*SearchRequest)(nil), // 1: google.SearchRequest
(*SearchResponse)(nil), // 2: google.SearchResponse
}
var file_proto_google_proto_depIdxs = []int32{
0, // 0: google.SearchResponse.results:type_name -> google.SearchResult
1, // 1: google.Google.Search:input_type -> google.SearchRequest
2, // 2: google.Google.Search:output_type -> google.SearchResponse
2, // [2:3] is the sub-list for method output_type
1, // [1:2] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_proto_google_proto_init() }
func file_proto_google_proto_init() {
if File_proto_google_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_google_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SearchResult); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_google_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SearchRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_google_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SearchResponse); 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_proto_google_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_google_proto_goTypes,
DependencyIndexes: file_proto_google_proto_depIdxs,
MessageInfos: file_proto_google_proto_msgTypes,
}.Build()
File_proto_google_proto = out.File
file_proto_google_proto_rawDesc = nil
file_proto_google_proto_goTypes = nil
file_proto_google_proto_depIdxs = nil
}