ud859

package module
v0.0.0-...-0f08ec5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2017 License: BSD-3-Clause Imports: 22 Imported by: 0

README

ud859 GoDoc

This project is an implementation of the udacity course at http://udacity.com/course/ud859 with the Go programming language.

The application is running at https://ud859-go.appspot.com and exposes a REST API to manage conferences using the Cloud Endpoints feature of Google App Engine.

Feedback

  • For the curious

The conference API endpoint is also queryable from apis-explorer.appspot.com.

  • When developping the API endpoint

Make sure that your endpoint is readable by the discovery service. This URL http://localhost:8080/_ah/api/discovery/v1/apis/conference/v1/rest should return the service endpoint description.

  • Testing

You can run the tests with go test (no need for goapp test) and take advantage of parallel subtests of go1.7.

  • My Eureka moment

When I managed to fake the endpoint authentication in the tests.

Documentation

Overview

Package ud859 is an implementation of the udacity course at http://udacity.com/course/ud859.

Index

Constants

View Source
const (
	EQ  = "="
	LT  = "<"
	GT  = ">"
	LTE = "<="
	GTE = ">="
	NE  = "!="
)

Supported query operators.

View Source
const (
	Name           = "NAME"
	City           = "CITY"
	Topics         = "TOPIC"
	StartDate      = "START_DATE"
	EndDate        = "END_DATE"
	Month          = "MONTH"
	MaxAttendees   = "MAX_ATTENDEES"
	SeatsAvailable = "SEATS_AVAILABLE"
)

Conference query fields.

Variables

This section is empty.

Functions

func RegisterConferenceAPI

func RegisterConferenceAPI(server *endpoints.Server) error

RegisterConferenceAPI adds the ConferenceAPI to the server.

Types

type Conference

type Conference struct {
	WebsafeKey     string    `json:"websafeKey" datastore:"-"`
	Name           string    `json:"name" datastore:",noindex"`
	Description    string    `json:"description" datastore:",noindex"`
	Organizer      string    `json:"organizerDisplayName" datastore:",noindex"`
	Topics         []string  `json:"topics" datastore:",noindex"`
	City           string    `json:"city" datastore:",noindex"`
	StartDate      time.Time `json:"startDate" datastore:"START_DATE"`
	EndDate        time.Time `json:"endDate" datastore:",noindex"`
	Month          int       `json:"-" datastore:",noindex"`
	MaxAttendees   int       `json:"maxAttendees" datastore:",noindex"`
	SeatsAvailable int       `json:"seatsAvailable" datastore:",noindex"`
}

Conference defines a conference.

type ConferenceAPI

type ConferenceAPI struct{}

ConferenceAPI defines the conferences management API.

func (ConferenceAPI) CancelConference

func (ConferenceAPI) CancelConference(c context.Context, form *ConferenceKeyForm) error

CancelConference cancels the registration to the specified ConferenceKeyForm.

func (ConferenceAPI) ConferencesCreated

func (ConferenceAPI) ConferencesCreated(c context.Context) (*Conferences, error)

ConferencesCreated returns the Conferences created by the current user.

func (ConferenceAPI) ConferencesToAttend

func (ConferenceAPI) ConferencesToAttend(c context.Context) (*Conferences, error)

ConferencesToAttend returns the Conferences to attend by the current user.

func (ConferenceAPI) CreateConference

func (ConferenceAPI) CreateConference(c context.Context, form *ConferenceForm) (*ConferenceCreated, error)

CreateConference creates a Conference in the datastore from the specified ConferenceForm.

func (ConferenceAPI) GetConference

func (ConferenceAPI) GetConference(c context.Context, form *ConferenceKeyForm) (*Conference, error)

GetConference returns the Conference with the specified ConferenceKeyForm.

func (ConferenceAPI) GetProfile

func (ConferenceAPI) GetProfile(c context.Context) (*Profile, error)

GetProfile returns the Profile associated with the current user.

func (ConferenceAPI) GotoConference

func (ConferenceAPI) GotoConference(c context.Context, form *ConferenceKeyForm) error

GotoConference performs the registration to the specified ConferenceKeyForm.

func (ConferenceAPI) QueryConferences

func (ConferenceAPI) QueryConferences(c context.Context, form *ConferenceQueryForm) (*Conferences, error)

QueryConferences searches for Conferences with the specified ConferenceQueryForm.

func (ConferenceAPI) SaveProfile

func (ConferenceAPI) SaveProfile(c context.Context, form *ProfileForm) error

SaveProfile saves the current user's Profile in the datastore from the specified ProfileForm.

type ConferenceCreated

type ConferenceCreated struct {
	Name       string `json:"name"`
	WebsafeKey string `json:"websafeConferenceKey"`
}

ConferenceCreated is returned when a conference is created.

type ConferenceForm

type ConferenceForm struct {
	Name         string   `json:"name" endpoints:"req"`
	Description  string   `json:"description"`
	Topics       []string `json:"topics"`
	City         string   `json:"city"`
	StartDate    string   `json:"startDate"`
	EndDate      string   `json:"endDate"`
	MaxAttendees string   `json:"maxAttendees"`
}

ConferenceForm gives details about a conference to create.

type ConferenceKeyForm

type ConferenceKeyForm struct {
	WebsafeKey string `json:"websafeConferenceKey" endpoints:"req"`
}

ConferenceKeyForm wraps a conference websafeKey.

type ConferenceQueryForm

type ConferenceQueryForm struct {
	Filters []*Filter `json:"filters"`
}

ConferenceQueryForm wraps a list of filters.

func (*ConferenceQueryForm) Filter

func (q *ConferenceQueryForm) Filter(field string, op string, value interface{}) *ConferenceQueryForm

Filter adds a restriction to the ConferenceQueryForm.

type Conferences

type Conferences struct {
	Items []*Conference `json:"items"`
}

Conferences is a list of Conferences.

func (Conferences) Len

func (c Conferences) Len() int

func (Conferences) Less

func (c Conferences) Less(i, j int) bool

func (Conferences) Swap

func (c Conferences) Swap(i, j int)

type Filter

type Filter struct {
	Field string      `endpoints:"req"`
	Op    string      `endpoints:"req"`
	Value interface{} `endpoints:"req"`
}

Filter describes a query restriction.

func (*Filter) MarshalJSON

func (f *Filter) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Filter as JSON data.

func (*Filter) UnmarshalJSON

func (f *Filter) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the JSON data into the Filter.

type Profile

type Profile struct {
	Email        string `json:"-"`
	DisplayName  string `json:"displayName"`
	TeeShirtSize string `json:"teeShirtSize"`
	// Conferences is a list of conferences WebsafeKey.
	Conferences []string `json:"conferenceKeysToAttend"`
}

Profile defines an identified user.

func (Profile) IsRegistered

func (p Profile) IsRegistered(websafeKey string) bool

IsRegistered returns true if the user is registered to the specified conference websafeKey.

type ProfileForm

type ProfileForm struct {
	DisplayName  string `json:"displayName"`
	TeeShirtSize string `json:"teeShirtSize"`
}

ProfileForm gives details about a Profile to create or update.

Jump to

Keyboard shortcuts

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