classroom-gen.go 135 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847
  1. // Package classroom provides access to the Google Classroom API.
  2. //
  3. // See https://developers.google.com/classroom/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/classroom/v1"
  8. // ...
  9. // classroomService, err := classroom.New(oauthHttpClient)
  10. package classroom // import "google.golang.org/api/classroom/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "classroom:v1"
  41. const apiName = "classroom"
  42. const apiVersion = "v1"
  43. const basePath = "https://classroom.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Manage your Google Classroom classes
  47. ClassroomCoursesScope = "https://www.googleapis.com/auth/classroom.courses"
  48. // View your Google Classroom classes
  49. ClassroomCoursesReadonlyScope = "https://www.googleapis.com/auth/classroom.courses.readonly"
  50. // View the email addresses of people in your classes
  51. ClassroomProfileEmailsScope = "https://www.googleapis.com/auth/classroom.profile.emails"
  52. // View the profile photos of people in your classes
  53. ClassroomProfilePhotosScope = "https://www.googleapis.com/auth/classroom.profile.photos"
  54. // Manage your Google Classroom class rosters
  55. ClassroomRostersScope = "https://www.googleapis.com/auth/classroom.rosters"
  56. // View your Google Classroom class rosters
  57. ClassroomRostersReadonlyScope = "https://www.googleapis.com/auth/classroom.rosters.readonly"
  58. )
  59. func New(client *http.Client) (*Service, error) {
  60. if client == nil {
  61. return nil, errors.New("client is nil")
  62. }
  63. s := &Service{client: client, BasePath: basePath}
  64. s.Courses = NewCoursesService(s)
  65. s.Invitations = NewInvitationsService(s)
  66. s.UserProfiles = NewUserProfilesService(s)
  67. return s, nil
  68. }
  69. type Service struct {
  70. client *http.Client
  71. BasePath string // API endpoint base URL
  72. UserAgent string // optional additional User-Agent fragment
  73. Courses *CoursesService
  74. Invitations *InvitationsService
  75. UserProfiles *UserProfilesService
  76. }
  77. func (s *Service) userAgent() string {
  78. if s.UserAgent == "" {
  79. return googleapi.UserAgent
  80. }
  81. return googleapi.UserAgent + " " + s.UserAgent
  82. }
  83. func NewCoursesService(s *Service) *CoursesService {
  84. rs := &CoursesService{s: s}
  85. rs.Aliases = NewCoursesAliasesService(s)
  86. rs.Students = NewCoursesStudentsService(s)
  87. rs.Teachers = NewCoursesTeachersService(s)
  88. return rs
  89. }
  90. type CoursesService struct {
  91. s *Service
  92. Aliases *CoursesAliasesService
  93. Students *CoursesStudentsService
  94. Teachers *CoursesTeachersService
  95. }
  96. func NewCoursesAliasesService(s *Service) *CoursesAliasesService {
  97. rs := &CoursesAliasesService{s: s}
  98. return rs
  99. }
  100. type CoursesAliasesService struct {
  101. s *Service
  102. }
  103. func NewCoursesStudentsService(s *Service) *CoursesStudentsService {
  104. rs := &CoursesStudentsService{s: s}
  105. return rs
  106. }
  107. type CoursesStudentsService struct {
  108. s *Service
  109. }
  110. func NewCoursesTeachersService(s *Service) *CoursesTeachersService {
  111. rs := &CoursesTeachersService{s: s}
  112. return rs
  113. }
  114. type CoursesTeachersService struct {
  115. s *Service
  116. }
  117. func NewInvitationsService(s *Service) *InvitationsService {
  118. rs := &InvitationsService{s: s}
  119. return rs
  120. }
  121. type InvitationsService struct {
  122. s *Service
  123. }
  124. func NewUserProfilesService(s *Service) *UserProfilesService {
  125. rs := &UserProfilesService{s: s}
  126. return rs
  127. }
  128. type UserProfilesService struct {
  129. s *Service
  130. }
  131. // Course: A Course in Classroom.
  132. type Course struct {
  133. // AlternateLink: Absolute link to this course in the Classroom web UI.
  134. // Read-only.
  135. AlternateLink string `json:"alternateLink,omitempty"`
  136. // CourseState: State of the course. If unspecified, the default state
  137. // is `PROVISIONED`.
  138. //
  139. // Possible values:
  140. // "COURSE_STATE_UNSPECIFIED"
  141. // "ACTIVE"
  142. // "ARCHIVED"
  143. // "PROVISIONED"
  144. // "DECLINED"
  145. CourseState string `json:"courseState,omitempty"`
  146. // CreationTime: Creation time of the course. Specifying this field in a
  147. // course update mask will result in an error. Read-only.
  148. CreationTime string `json:"creationTime,omitempty"`
  149. // Description: Optional description. For example, "We'll be learning
  150. // about the structure of living creatures from a combination of
  151. // textbooks, guest lectures, and lab work. Expect to be excited!" If
  152. // set, this field must be a valid UTF-8 string and no longer than
  153. // 30,000 characters.
  154. Description string `json:"description,omitempty"`
  155. // DescriptionHeading: Optional heading for the description. For
  156. // example, "Welcome to 10th Grade Biology." If set, this field must be
  157. // a valid UTF-8 string and no longer than 3600 characters.
  158. DescriptionHeading string `json:"descriptionHeading,omitempty"`
  159. // EnrollmentCode: Enrollment code to use when joining this course.
  160. // Specifying this field in a course update mask will result in an
  161. // error. Read-only.
  162. EnrollmentCode string `json:"enrollmentCode,omitempty"`
  163. // Id: Identifier for this course assigned by Classroom. When creating a
  164. // course, you may optionally set this identifier to an alias string in
  165. // the request to create a corresponding alias. The `id` is still
  166. // assigned by Classroom and cannot be updated after the course is
  167. // created. Specifying this field in a course update mask will result in
  168. // an error.
  169. Id string `json:"id,omitempty"`
  170. // Name: Name of the course. For example, "10th Grade Biology". The name
  171. // is required. It must be between 1 and 750 characters and a valid
  172. // UTF-8 string.
  173. Name string `json:"name,omitempty"`
  174. // OwnerId: The identifier of the owner of a course. When specified as a
  175. // parameter of a create course request, this field is required. The
  176. // identifier can be one of the following: * the numeric identifier for
  177. // the user * the email address of the user * the string literal "me",
  178. // indicating the requesting user This must be set in a create request.
  179. // Specifying this field in a course update mask will result in an
  180. // `INVALID_ARGUMENT` error.
  181. OwnerId string `json:"ownerId,omitempty"`
  182. // Room: Optional room location. For example, "301". If set, this field
  183. // must be a valid UTF-8 string and no longer than 650 characters.
  184. Room string `json:"room,omitempty"`
  185. // Section: Section of the course. For example, "Period 2". If set, this
  186. // field must be a valid UTF-8 string and no longer than 2800
  187. // characters.
  188. Section string `json:"section,omitempty"`
  189. // UpdateTime: Time of the most recent update to this course. Specifying
  190. // this field in a course update mask will result in an error.
  191. // Read-only.
  192. UpdateTime string `json:"updateTime,omitempty"`
  193. // ServerResponse contains the HTTP response code and headers from the
  194. // server.
  195. googleapi.ServerResponse `json:"-"`
  196. // ForceSendFields is a list of field names (e.g. "AlternateLink") to
  197. // unconditionally include in API requests. By default, fields with
  198. // empty values are omitted from API requests. However, any non-pointer,
  199. // non-interface field appearing in ForceSendFields will be sent to the
  200. // server regardless of whether the field is empty or not. This may be
  201. // used to include empty fields in Patch requests.
  202. ForceSendFields []string `json:"-"`
  203. }
  204. func (s *Course) MarshalJSON() ([]byte, error) {
  205. type noMethod Course
  206. raw := noMethod(*s)
  207. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  208. }
  209. // CourseAlias: Alternative identifier for a course. An alias uniquely
  210. // identifies a course. It must be unique within one of the following
  211. // scopes: * domain: A domain-scoped alias is visible to all users
  212. // within the alias creator's domain and can be created only by a domain
  213. // admin. A domain-scoped alias is often used when a course has an
  214. // identifier external to Classroom. * project: A project-scoped alias
  215. // is visible to any request from an application using the Developer
  216. // Console project ID that created the alias and can be created by any
  217. // project. A project-scoped alias is often used when an application has
  218. // alternative identifiers. A random value can also be used to avoid
  219. // duplicate courses in the event of transmission failures, as retrying
  220. // a request will return `ALREADY_EXISTS` if a previous one has
  221. // succeeded.
  222. type CourseAlias struct {
  223. // Alias: Alias string. The format of the string indicates the desired
  224. // alias scoping. * `d:` indicates a domain-scoped alias. Example:
  225. // `d:math_101` * `p:` indicates a project-scoped alias. Example:
  226. // `p:abc123` This field has a maximum length of 256 characters.
  227. Alias string `json:"alias,omitempty"`
  228. // ServerResponse contains the HTTP response code and headers from the
  229. // server.
  230. googleapi.ServerResponse `json:"-"`
  231. // ForceSendFields is a list of field names (e.g. "Alias") to
  232. // unconditionally include in API requests. By default, fields with
  233. // empty values are omitted from API requests. However, any non-pointer,
  234. // non-interface field appearing in ForceSendFields will be sent to the
  235. // server regardless of whether the field is empty or not. This may be
  236. // used to include empty fields in Patch requests.
  237. ForceSendFields []string `json:"-"`
  238. }
  239. func (s *CourseAlias) MarshalJSON() ([]byte, error) {
  240. type noMethod CourseAlias
  241. raw := noMethod(*s)
  242. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  243. }
  244. // Empty: A generic empty message that you can re-use to avoid defining
  245. // duplicated empty messages in your APIs. A typical example is to use
  246. // it as the request or the response type of an API method. For
  247. // instance: service Foo { rpc Bar(google.protobuf.Empty) returns
  248. // (google.protobuf.Empty); } The JSON representation for `Empty` is
  249. // empty JSON object `{}`.
  250. type Empty struct {
  251. // ServerResponse contains the HTTP response code and headers from the
  252. // server.
  253. googleapi.ServerResponse `json:"-"`
  254. }
  255. // GlobalPermission: Global user permission description.
  256. type GlobalPermission struct {
  257. // Permission: Permission value.
  258. //
  259. // Possible values:
  260. // "PERMISSION_UNSPECIFIED"
  261. // "CREATE_COURSE"
  262. Permission string `json:"permission,omitempty"`
  263. // ForceSendFields is a list of field names (e.g. "Permission") to
  264. // unconditionally include in API requests. By default, fields with
  265. // empty values are omitted from API requests. However, any non-pointer,
  266. // non-interface field appearing in ForceSendFields will be sent to the
  267. // server regardless of whether the field is empty or not. This may be
  268. // used to include empty fields in Patch requests.
  269. ForceSendFields []string `json:"-"`
  270. }
  271. func (s *GlobalPermission) MarshalJSON() ([]byte, error) {
  272. type noMethod GlobalPermission
  273. raw := noMethod(*s)
  274. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  275. }
  276. // Invitation: An invitation to join a course.
  277. type Invitation struct {
  278. // CourseId: Identifier of the course to invite the user to.
  279. CourseId string `json:"courseId,omitempty"`
  280. // Id: Identifier assigned by Classroom. Read-only.
  281. Id string `json:"id,omitempty"`
  282. // Role: Role to invite the user to have. Must not be
  283. // `COURSE_ROLE_UNSPECIFIED`.
  284. //
  285. // Possible values:
  286. // "COURSE_ROLE_UNSPECIFIED"
  287. // "STUDENT"
  288. // "TEACHER"
  289. Role string `json:"role,omitempty"`
  290. // UserId: Identifier of the invited user. When specified as a parameter
  291. // of a request, this identifier can be set to one of the following: *
  292. // the numeric identifier for the user * the email address of the user *
  293. // the string literal "me", indicating the requesting user
  294. UserId string `json:"userId,omitempty"`
  295. // ServerResponse contains the HTTP response code and headers from the
  296. // server.
  297. googleapi.ServerResponse `json:"-"`
  298. // ForceSendFields is a list of field names (e.g. "CourseId") to
  299. // unconditionally include in API requests. By default, fields with
  300. // empty values are omitted from API requests. However, any non-pointer,
  301. // non-interface field appearing in ForceSendFields will be sent to the
  302. // server regardless of whether the field is empty or not. This may be
  303. // used to include empty fields in Patch requests.
  304. ForceSendFields []string `json:"-"`
  305. }
  306. func (s *Invitation) MarshalJSON() ([]byte, error) {
  307. type noMethod Invitation
  308. raw := noMethod(*s)
  309. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  310. }
  311. // ListCourseAliasesResponse: Response when listing course aliases.
  312. type ListCourseAliasesResponse struct {
  313. // Aliases: The course aliases.
  314. Aliases []*CourseAlias `json:"aliases,omitempty"`
  315. // NextPageToken: Token identifying the next page of results to return.
  316. // If empty, no further results are available.
  317. NextPageToken string `json:"nextPageToken,omitempty"`
  318. // ServerResponse contains the HTTP response code and headers from the
  319. // server.
  320. googleapi.ServerResponse `json:"-"`
  321. // ForceSendFields is a list of field names (e.g. "Aliases") to
  322. // unconditionally include in API requests. By default, fields with
  323. // empty values are omitted from API requests. However, any non-pointer,
  324. // non-interface field appearing in ForceSendFields will be sent to the
  325. // server regardless of whether the field is empty or not. This may be
  326. // used to include empty fields in Patch requests.
  327. ForceSendFields []string `json:"-"`
  328. }
  329. func (s *ListCourseAliasesResponse) MarshalJSON() ([]byte, error) {
  330. type noMethod ListCourseAliasesResponse
  331. raw := noMethod(*s)
  332. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  333. }
  334. // ListCoursesResponse: Response when listing courses.
  335. type ListCoursesResponse struct {
  336. // Courses: Courses that match the list request.
  337. Courses []*Course `json:"courses,omitempty"`
  338. // NextPageToken: Token identifying the next page of results to return.
  339. // If empty, no further results are available.
  340. NextPageToken string `json:"nextPageToken,omitempty"`
  341. // ServerResponse contains the HTTP response code and headers from the
  342. // server.
  343. googleapi.ServerResponse `json:"-"`
  344. // ForceSendFields is a list of field names (e.g. "Courses") to
  345. // unconditionally include in API requests. By default, fields with
  346. // empty values are omitted from API requests. However, any non-pointer,
  347. // non-interface field appearing in ForceSendFields will be sent to the
  348. // server regardless of whether the field is empty or not. This may be
  349. // used to include empty fields in Patch requests.
  350. ForceSendFields []string `json:"-"`
  351. }
  352. func (s *ListCoursesResponse) MarshalJSON() ([]byte, error) {
  353. type noMethod ListCoursesResponse
  354. raw := noMethod(*s)
  355. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  356. }
  357. // ListInvitationsResponse: Response when listing invitations.
  358. type ListInvitationsResponse struct {
  359. // Invitations: Invitations that match the list request.
  360. Invitations []*Invitation `json:"invitations,omitempty"`
  361. // NextPageToken: Token identifying the next page of results to return.
  362. // If empty, no further results are available.
  363. NextPageToken string `json:"nextPageToken,omitempty"`
  364. // ServerResponse contains the HTTP response code and headers from the
  365. // server.
  366. googleapi.ServerResponse `json:"-"`
  367. // ForceSendFields is a list of field names (e.g. "Invitations") to
  368. // unconditionally include in API requests. By default, fields with
  369. // empty values are omitted from API requests. However, any non-pointer,
  370. // non-interface field appearing in ForceSendFields will be sent to the
  371. // server regardless of whether the field is empty or not. This may be
  372. // used to include empty fields in Patch requests.
  373. ForceSendFields []string `json:"-"`
  374. }
  375. func (s *ListInvitationsResponse) MarshalJSON() ([]byte, error) {
  376. type noMethod ListInvitationsResponse
  377. raw := noMethod(*s)
  378. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  379. }
  380. // ListStudentsResponse: Response when listing students.
  381. type ListStudentsResponse struct {
  382. // NextPageToken: Token identifying the next page of results to return.
  383. // If empty, no further results are available.
  384. NextPageToken string `json:"nextPageToken,omitempty"`
  385. // Students: Students who match the list request.
  386. Students []*Student `json:"students,omitempty"`
  387. // ServerResponse contains the HTTP response code and headers from the
  388. // server.
  389. googleapi.ServerResponse `json:"-"`
  390. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  391. // unconditionally include in API requests. By default, fields with
  392. // empty values are omitted from API requests. However, any non-pointer,
  393. // non-interface field appearing in ForceSendFields will be sent to the
  394. // server regardless of whether the field is empty or not. This may be
  395. // used to include empty fields in Patch requests.
  396. ForceSendFields []string `json:"-"`
  397. }
  398. func (s *ListStudentsResponse) MarshalJSON() ([]byte, error) {
  399. type noMethod ListStudentsResponse
  400. raw := noMethod(*s)
  401. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  402. }
  403. // ListTeachersResponse: Response when listing teachers.
  404. type ListTeachersResponse struct {
  405. // NextPageToken: Token identifying the next page of results to return.
  406. // If empty, no further results are available.
  407. NextPageToken string `json:"nextPageToken,omitempty"`
  408. // Teachers: Teachers who match the list request.
  409. Teachers []*Teacher `json:"teachers,omitempty"`
  410. // ServerResponse contains the HTTP response code and headers from the
  411. // server.
  412. googleapi.ServerResponse `json:"-"`
  413. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  414. // unconditionally include in API requests. By default, fields with
  415. // empty values are omitted from API requests. However, any non-pointer,
  416. // non-interface field appearing in ForceSendFields will be sent to the
  417. // server regardless of whether the field is empty or not. This may be
  418. // used to include empty fields in Patch requests.
  419. ForceSendFields []string `json:"-"`
  420. }
  421. func (s *ListTeachersResponse) MarshalJSON() ([]byte, error) {
  422. type noMethod ListTeachersResponse
  423. raw := noMethod(*s)
  424. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  425. }
  426. // Name: Details of the user's name.
  427. type Name struct {
  428. // FamilyName: The user's last name. Read-only.
  429. FamilyName string `json:"familyName,omitempty"`
  430. // FullName: The user's full name formed by concatenating the first and
  431. // last name values. Read-only.
  432. FullName string `json:"fullName,omitempty"`
  433. // GivenName: The user's first name. Read-only.
  434. GivenName string `json:"givenName,omitempty"`
  435. // ForceSendFields is a list of field names (e.g. "FamilyName") to
  436. // unconditionally include in API requests. By default, fields with
  437. // empty values are omitted from API requests. However, any non-pointer,
  438. // non-interface field appearing in ForceSendFields will be sent to the
  439. // server regardless of whether the field is empty or not. This may be
  440. // used to include empty fields in Patch requests.
  441. ForceSendFields []string `json:"-"`
  442. }
  443. func (s *Name) MarshalJSON() ([]byte, error) {
  444. type noMethod Name
  445. raw := noMethod(*s)
  446. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  447. }
  448. // Student: Student in a course.
  449. type Student struct {
  450. // CourseId: Identifier of the course. Read-only.
  451. CourseId string `json:"courseId,omitempty"`
  452. // Profile: Global user information for the student. Read-only.
  453. Profile *UserProfile `json:"profile,omitempty"`
  454. // UserId: Identifier of the user. When specified as a parameter of a
  455. // request, this identifier can be one of the following: * the numeric
  456. // identifier for the user * the email address of the user * the string
  457. // literal "me", indicating the requesting user
  458. UserId string `json:"userId,omitempty"`
  459. // ServerResponse contains the HTTP response code and headers from the
  460. // server.
  461. googleapi.ServerResponse `json:"-"`
  462. // ForceSendFields is a list of field names (e.g. "CourseId") to
  463. // unconditionally include in API requests. By default, fields with
  464. // empty values are omitted from API requests. However, any non-pointer,
  465. // non-interface field appearing in ForceSendFields will be sent to the
  466. // server regardless of whether the field is empty or not. This may be
  467. // used to include empty fields in Patch requests.
  468. ForceSendFields []string `json:"-"`
  469. }
  470. func (s *Student) MarshalJSON() ([]byte, error) {
  471. type noMethod Student
  472. raw := noMethod(*s)
  473. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  474. }
  475. // Teacher: Teacher of a course.
  476. type Teacher struct {
  477. // CourseId: Identifier of the course. Read-only.
  478. CourseId string `json:"courseId,omitempty"`
  479. // Profile: Global user information for the teacher. Read-only.
  480. Profile *UserProfile `json:"profile,omitempty"`
  481. // UserId: Identifier of the user. When specified as a parameter of a
  482. // request, this identifier can be one of the following: * the numeric
  483. // identifier for the user * the email address of the user * the string
  484. // literal "me", indicating the requesting user
  485. UserId string `json:"userId,omitempty"`
  486. // ServerResponse contains the HTTP response code and headers from the
  487. // server.
  488. googleapi.ServerResponse `json:"-"`
  489. // ForceSendFields is a list of field names (e.g. "CourseId") to
  490. // unconditionally include in API requests. By default, fields with
  491. // empty values are omitted from API requests. However, any non-pointer,
  492. // non-interface field appearing in ForceSendFields will be sent to the
  493. // server regardless of whether the field is empty or not. This may be
  494. // used to include empty fields in Patch requests.
  495. ForceSendFields []string `json:"-"`
  496. }
  497. func (s *Teacher) MarshalJSON() ([]byte, error) {
  498. type noMethod Teacher
  499. raw := noMethod(*s)
  500. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  501. }
  502. // UserProfile: Global information for a user.
  503. type UserProfile struct {
  504. // EmailAddress: Email address of the user. Read-only.
  505. EmailAddress string `json:"emailAddress,omitempty"`
  506. // Id: Identifier of the user. Read-only.
  507. Id string `json:"id,omitempty"`
  508. // Name: Name of the user. Read-only.
  509. Name *Name `json:"name,omitempty"`
  510. // Permissions: Global permissions of the user. Read-only.
  511. Permissions []*GlobalPermission `json:"permissions,omitempty"`
  512. // PhotoUrl: URL of user's profile photo. Read-only.
  513. PhotoUrl string `json:"photoUrl,omitempty"`
  514. // ServerResponse contains the HTTP response code and headers from the
  515. // server.
  516. googleapi.ServerResponse `json:"-"`
  517. // ForceSendFields is a list of field names (e.g. "EmailAddress") to
  518. // unconditionally include in API requests. By default, fields with
  519. // empty values are omitted from API requests. However, any non-pointer,
  520. // non-interface field appearing in ForceSendFields will be sent to the
  521. // server regardless of whether the field is empty or not. This may be
  522. // used to include empty fields in Patch requests.
  523. ForceSendFields []string `json:"-"`
  524. }
  525. func (s *UserProfile) MarshalJSON() ([]byte, error) {
  526. type noMethod UserProfile
  527. raw := noMethod(*s)
  528. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  529. }
  530. // method id "classroom.courses.create":
  531. type CoursesCreateCall struct {
  532. s *Service
  533. course *Course
  534. urlParams_ gensupport.URLParams
  535. ctx_ context.Context
  536. }
  537. // Create: Creates a course. The user specified in `ownerId` is the
  538. // owner of the created course and added as a teacher. This method
  539. // returns the following error codes: * `PERMISSION_DENIED` if the
  540. // requesting user is not permitted to create courses or for access
  541. // errors. * `NOT_FOUND` if the primary teacher is not a valid user. *
  542. // `FAILED_PRECONDITION` if the course owner's account is disabled or
  543. // for the following request errors: * UserGroupsMembershipLimitReached
  544. // * `ALREADY_EXISTS` if an alias was specified in the `id` and already
  545. // exists.
  546. func (r *CoursesService) Create(course *Course) *CoursesCreateCall {
  547. c := &CoursesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  548. c.course = course
  549. return c
  550. }
  551. // Fields allows partial responses to be retrieved. See
  552. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  553. // for more information.
  554. func (c *CoursesCreateCall) Fields(s ...googleapi.Field) *CoursesCreateCall {
  555. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  556. return c
  557. }
  558. // Context sets the context to be used in this call's Do method. Any
  559. // pending HTTP request will be aborted if the provided context is
  560. // canceled.
  561. func (c *CoursesCreateCall) Context(ctx context.Context) *CoursesCreateCall {
  562. c.ctx_ = ctx
  563. return c
  564. }
  565. func (c *CoursesCreateCall) doRequest(alt string) (*http.Response, error) {
  566. var body io.Reader = nil
  567. body, err := googleapi.WithoutDataWrapper.JSONReader(c.course)
  568. if err != nil {
  569. return nil, err
  570. }
  571. ctype := "application/json"
  572. c.urlParams_.Set("alt", alt)
  573. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses")
  574. urls += "?" + c.urlParams_.Encode()
  575. req, _ := http.NewRequest("POST", urls, body)
  576. googleapi.SetOpaque(req.URL)
  577. req.Header.Set("Content-Type", ctype)
  578. req.Header.Set("User-Agent", c.s.userAgent())
  579. if c.ctx_ != nil {
  580. return ctxhttp.Do(c.ctx_, c.s.client, req)
  581. }
  582. return c.s.client.Do(req)
  583. }
  584. // Do executes the "classroom.courses.create" call.
  585. // Exactly one of *Course or error will be non-nil. Any non-2xx status
  586. // code is an error. Response headers are in either
  587. // *Course.ServerResponse.Header or (if a response was returned at all)
  588. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  589. // check whether the returned error was because http.StatusNotModified
  590. // was returned.
  591. func (c *CoursesCreateCall) Do(opts ...googleapi.CallOption) (*Course, error) {
  592. gensupport.SetOptions(c.urlParams_, opts...)
  593. res, err := c.doRequest("json")
  594. if res != nil && res.StatusCode == http.StatusNotModified {
  595. if res.Body != nil {
  596. res.Body.Close()
  597. }
  598. return nil, &googleapi.Error{
  599. Code: res.StatusCode,
  600. Header: res.Header,
  601. }
  602. }
  603. if err != nil {
  604. return nil, err
  605. }
  606. defer googleapi.CloseBody(res)
  607. if err := googleapi.CheckResponse(res); err != nil {
  608. return nil, err
  609. }
  610. ret := &Course{
  611. ServerResponse: googleapi.ServerResponse{
  612. Header: res.Header,
  613. HTTPStatusCode: res.StatusCode,
  614. },
  615. }
  616. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  617. return nil, err
  618. }
  619. return ret, nil
  620. // {
  621. // "description": "Creates a course. The user specified in `ownerId` is the owner of the created course and added as a teacher. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create courses or for access errors. * `NOT_FOUND` if the primary teacher is not a valid user. * `FAILED_PRECONDITION` if the course owner's account is disabled or for the following request errors: * UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if an alias was specified in the `id` and already exists.",
  622. // "httpMethod": "POST",
  623. // "id": "classroom.courses.create",
  624. // "path": "v1/courses",
  625. // "request": {
  626. // "$ref": "Course"
  627. // },
  628. // "response": {
  629. // "$ref": "Course"
  630. // },
  631. // "scopes": [
  632. // "https://www.googleapis.com/auth/classroom.courses"
  633. // ]
  634. // }
  635. }
  636. // method id "classroom.courses.delete":
  637. type CoursesDeleteCall struct {
  638. s *Service
  639. id string
  640. urlParams_ gensupport.URLParams
  641. ctx_ context.Context
  642. }
  643. // Delete: Deletes a course. This method returns the following error
  644. // codes: * `PERMISSION_DENIED` if the requesting user is not permitted
  645. // to delete the requested course or for access errors. * `NOT_FOUND` if
  646. // no course exists with the requested ID.
  647. func (r *CoursesService) Delete(id string) *CoursesDeleteCall {
  648. c := &CoursesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  649. c.id = id
  650. return c
  651. }
  652. // Fields allows partial responses to be retrieved. See
  653. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  654. // for more information.
  655. func (c *CoursesDeleteCall) Fields(s ...googleapi.Field) *CoursesDeleteCall {
  656. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  657. return c
  658. }
  659. // Context sets the context to be used in this call's Do method. Any
  660. // pending HTTP request will be aborted if the provided context is
  661. // canceled.
  662. func (c *CoursesDeleteCall) Context(ctx context.Context) *CoursesDeleteCall {
  663. c.ctx_ = ctx
  664. return c
  665. }
  666. func (c *CoursesDeleteCall) doRequest(alt string) (*http.Response, error) {
  667. var body io.Reader = nil
  668. c.urlParams_.Set("alt", alt)
  669. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{id}")
  670. urls += "?" + c.urlParams_.Encode()
  671. req, _ := http.NewRequest("DELETE", urls, body)
  672. googleapi.Expand(req.URL, map[string]string{
  673. "id": c.id,
  674. })
  675. req.Header.Set("User-Agent", c.s.userAgent())
  676. if c.ctx_ != nil {
  677. return ctxhttp.Do(c.ctx_, c.s.client, req)
  678. }
  679. return c.s.client.Do(req)
  680. }
  681. // Do executes the "classroom.courses.delete" call.
  682. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  683. // code is an error. Response headers are in either
  684. // *Empty.ServerResponse.Header or (if a response was returned at all)
  685. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  686. // check whether the returned error was because http.StatusNotModified
  687. // was returned.
  688. func (c *CoursesDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  689. gensupport.SetOptions(c.urlParams_, opts...)
  690. res, err := c.doRequest("json")
  691. if res != nil && res.StatusCode == http.StatusNotModified {
  692. if res.Body != nil {
  693. res.Body.Close()
  694. }
  695. return nil, &googleapi.Error{
  696. Code: res.StatusCode,
  697. Header: res.Header,
  698. }
  699. }
  700. if err != nil {
  701. return nil, err
  702. }
  703. defer googleapi.CloseBody(res)
  704. if err := googleapi.CheckResponse(res); err != nil {
  705. return nil, err
  706. }
  707. ret := &Empty{
  708. ServerResponse: googleapi.ServerResponse{
  709. Header: res.Header,
  710. HTTPStatusCode: res.StatusCode,
  711. },
  712. }
  713. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  714. return nil, err
  715. }
  716. return ret, nil
  717. // {
  718. // "description": "Deletes a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID.",
  719. // "httpMethod": "DELETE",
  720. // "id": "classroom.courses.delete",
  721. // "parameterOrder": [
  722. // "id"
  723. // ],
  724. // "parameters": {
  725. // "id": {
  726. // "description": "Identifier of the course to delete. This identifier can be either the Classroom-assigned identifier or an alias.",
  727. // "location": "path",
  728. // "required": true,
  729. // "type": "string"
  730. // }
  731. // },
  732. // "path": "v1/courses/{id}",
  733. // "response": {
  734. // "$ref": "Empty"
  735. // },
  736. // "scopes": [
  737. // "https://www.googleapis.com/auth/classroom.courses"
  738. // ]
  739. // }
  740. }
  741. // method id "classroom.courses.get":
  742. type CoursesGetCall struct {
  743. s *Service
  744. id string
  745. urlParams_ gensupport.URLParams
  746. ifNoneMatch_ string
  747. ctx_ context.Context
  748. }
  749. // Get: Returns a course. This method returns the following error codes:
  750. // * `PERMISSION_DENIED` if the requesting user is not permitted to
  751. // access the requested course or for access errors. * `NOT_FOUND` if no
  752. // course exists with the requested ID.
  753. func (r *CoursesService) Get(id string) *CoursesGetCall {
  754. c := &CoursesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  755. c.id = id
  756. return c
  757. }
  758. // Fields allows partial responses to be retrieved. See
  759. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  760. // for more information.
  761. func (c *CoursesGetCall) Fields(s ...googleapi.Field) *CoursesGetCall {
  762. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  763. return c
  764. }
  765. // IfNoneMatch sets the optional parameter which makes the operation
  766. // fail if the object's ETag matches the given value. This is useful for
  767. // getting updates only after the object has changed since the last
  768. // request. Use googleapi.IsNotModified to check whether the response
  769. // error from Do is the result of In-None-Match.
  770. func (c *CoursesGetCall) IfNoneMatch(entityTag string) *CoursesGetCall {
  771. c.ifNoneMatch_ = entityTag
  772. return c
  773. }
  774. // Context sets the context to be used in this call's Do method. Any
  775. // pending HTTP request will be aborted if the provided context is
  776. // canceled.
  777. func (c *CoursesGetCall) Context(ctx context.Context) *CoursesGetCall {
  778. c.ctx_ = ctx
  779. return c
  780. }
  781. func (c *CoursesGetCall) doRequest(alt string) (*http.Response, error) {
  782. var body io.Reader = nil
  783. c.urlParams_.Set("alt", alt)
  784. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{id}")
  785. urls += "?" + c.urlParams_.Encode()
  786. req, _ := http.NewRequest("GET", urls, body)
  787. googleapi.Expand(req.URL, map[string]string{
  788. "id": c.id,
  789. })
  790. req.Header.Set("User-Agent", c.s.userAgent())
  791. if c.ifNoneMatch_ != "" {
  792. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  793. }
  794. if c.ctx_ != nil {
  795. return ctxhttp.Do(c.ctx_, c.s.client, req)
  796. }
  797. return c.s.client.Do(req)
  798. }
  799. // Do executes the "classroom.courses.get" call.
  800. // Exactly one of *Course or error will be non-nil. Any non-2xx status
  801. // code is an error. Response headers are in either
  802. // *Course.ServerResponse.Header or (if a response was returned at all)
  803. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  804. // check whether the returned error was because http.StatusNotModified
  805. // was returned.
  806. func (c *CoursesGetCall) Do(opts ...googleapi.CallOption) (*Course, error) {
  807. gensupport.SetOptions(c.urlParams_, opts...)
  808. res, err := c.doRequest("json")
  809. if res != nil && res.StatusCode == http.StatusNotModified {
  810. if res.Body != nil {
  811. res.Body.Close()
  812. }
  813. return nil, &googleapi.Error{
  814. Code: res.StatusCode,
  815. Header: res.Header,
  816. }
  817. }
  818. if err != nil {
  819. return nil, err
  820. }
  821. defer googleapi.CloseBody(res)
  822. if err := googleapi.CheckResponse(res); err != nil {
  823. return nil, err
  824. }
  825. ret := &Course{
  826. ServerResponse: googleapi.ServerResponse{
  827. Header: res.Header,
  828. HTTPStatusCode: res.StatusCode,
  829. },
  830. }
  831. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  832. return nil, err
  833. }
  834. return ret, nil
  835. // {
  836. // "description": "Returns a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID.",
  837. // "httpMethod": "GET",
  838. // "id": "classroom.courses.get",
  839. // "parameterOrder": [
  840. // "id"
  841. // ],
  842. // "parameters": {
  843. // "id": {
  844. // "description": "Identifier of the course to return. This identifier can be either the Classroom-assigned identifier or an alias.",
  845. // "location": "path",
  846. // "required": true,
  847. // "type": "string"
  848. // }
  849. // },
  850. // "path": "v1/courses/{id}",
  851. // "response": {
  852. // "$ref": "Course"
  853. // },
  854. // "scopes": [
  855. // "https://www.googleapis.com/auth/classroom.courses",
  856. // "https://www.googleapis.com/auth/classroom.courses.readonly"
  857. // ]
  858. // }
  859. }
  860. // method id "classroom.courses.list":
  861. type CoursesListCall struct {
  862. s *Service
  863. urlParams_ gensupport.URLParams
  864. ifNoneMatch_ string
  865. ctx_ context.Context
  866. }
  867. // List: Returns a list of courses that the requesting user is permitted
  868. // to view, restricted to those that match the request. This method
  869. // returns the following error codes: * `PERMISSION_DENIED` for access
  870. // errors. * `INVALID_ARGUMENT` if the query argument is malformed. *
  871. // `NOT_FOUND` if any users specified in the query arguments do not
  872. // exist.
  873. func (r *CoursesService) List() *CoursesListCall {
  874. c := &CoursesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  875. return c
  876. }
  877. // PageSize sets the optional parameter "pageSize": Maximum number of
  878. // items to return. Zero or unspecified indicates that the server may
  879. // assign a maximum. The server may return fewer than the specified
  880. // number of results.
  881. func (c *CoursesListCall) PageSize(pageSize int64) *CoursesListCall {
  882. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  883. return c
  884. }
  885. // PageToken sets the optional parameter "pageToken": nextPageToken
  886. // value returned from a previous list call, indicating that the
  887. // subsequent page of results should be returned. The list request must
  888. // be otherwise identical to the one that resulted in this token.
  889. func (c *CoursesListCall) PageToken(pageToken string) *CoursesListCall {
  890. c.urlParams_.Set("pageToken", pageToken)
  891. return c
  892. }
  893. // StudentId sets the optional parameter "studentId": Restricts returned
  894. // courses to those having a student with the specified identifier. The
  895. // identifier can be one of the following: * the numeric identifier for
  896. // the user * the email address of the user * the string literal "me",
  897. // indicating the requesting user
  898. func (c *CoursesListCall) StudentId(studentId string) *CoursesListCall {
  899. c.urlParams_.Set("studentId", studentId)
  900. return c
  901. }
  902. // TeacherId sets the optional parameter "teacherId": Restricts returned
  903. // courses to those having a teacher with the specified identifier. The
  904. // identifier can be one of the following: * the numeric identifier for
  905. // the user * the email address of the user * the string literal "me",
  906. // indicating the requesting user
  907. func (c *CoursesListCall) TeacherId(teacherId string) *CoursesListCall {
  908. c.urlParams_.Set("teacherId", teacherId)
  909. return c
  910. }
  911. // Fields allows partial responses to be retrieved. See
  912. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  913. // for more information.
  914. func (c *CoursesListCall) Fields(s ...googleapi.Field) *CoursesListCall {
  915. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  916. return c
  917. }
  918. // IfNoneMatch sets the optional parameter which makes the operation
  919. // fail if the object's ETag matches the given value. This is useful for
  920. // getting updates only after the object has changed since the last
  921. // request. Use googleapi.IsNotModified to check whether the response
  922. // error from Do is the result of In-None-Match.
  923. func (c *CoursesListCall) IfNoneMatch(entityTag string) *CoursesListCall {
  924. c.ifNoneMatch_ = entityTag
  925. return c
  926. }
  927. // Context sets the context to be used in this call's Do method. Any
  928. // pending HTTP request will be aborted if the provided context is
  929. // canceled.
  930. func (c *CoursesListCall) Context(ctx context.Context) *CoursesListCall {
  931. c.ctx_ = ctx
  932. return c
  933. }
  934. func (c *CoursesListCall) doRequest(alt string) (*http.Response, error) {
  935. var body io.Reader = nil
  936. c.urlParams_.Set("alt", alt)
  937. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses")
  938. urls += "?" + c.urlParams_.Encode()
  939. req, _ := http.NewRequest("GET", urls, body)
  940. googleapi.SetOpaque(req.URL)
  941. req.Header.Set("User-Agent", c.s.userAgent())
  942. if c.ifNoneMatch_ != "" {
  943. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  944. }
  945. if c.ctx_ != nil {
  946. return ctxhttp.Do(c.ctx_, c.s.client, req)
  947. }
  948. return c.s.client.Do(req)
  949. }
  950. // Do executes the "classroom.courses.list" call.
  951. // Exactly one of *ListCoursesResponse or error will be non-nil. Any
  952. // non-2xx status code is an error. Response headers are in either
  953. // *ListCoursesResponse.ServerResponse.Header or (if a response was
  954. // returned at all) in error.(*googleapi.Error).Header. Use
  955. // googleapi.IsNotModified to check whether the returned error was
  956. // because http.StatusNotModified was returned.
  957. func (c *CoursesListCall) Do(opts ...googleapi.CallOption) (*ListCoursesResponse, error) {
  958. gensupport.SetOptions(c.urlParams_, opts...)
  959. res, err := c.doRequest("json")
  960. if res != nil && res.StatusCode == http.StatusNotModified {
  961. if res.Body != nil {
  962. res.Body.Close()
  963. }
  964. return nil, &googleapi.Error{
  965. Code: res.StatusCode,
  966. Header: res.Header,
  967. }
  968. }
  969. if err != nil {
  970. return nil, err
  971. }
  972. defer googleapi.CloseBody(res)
  973. if err := googleapi.CheckResponse(res); err != nil {
  974. return nil, err
  975. }
  976. ret := &ListCoursesResponse{
  977. ServerResponse: googleapi.ServerResponse{
  978. Header: res.Header,
  979. HTTPStatusCode: res.StatusCode,
  980. },
  981. }
  982. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  983. return nil, err
  984. }
  985. return ret, nil
  986. // {
  987. // "description": "Returns a list of courses that the requesting user is permitted to view, restricted to those that match the request. This method returns the following error codes: * `PERMISSION_DENIED` for access errors. * `INVALID_ARGUMENT` if the query argument is malformed. * `NOT_FOUND` if any users specified in the query arguments do not exist.",
  988. // "httpMethod": "GET",
  989. // "id": "classroom.courses.list",
  990. // "parameters": {
  991. // "pageSize": {
  992. // "description": "Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.",
  993. // "format": "int32",
  994. // "location": "query",
  995. // "type": "integer"
  996. // },
  997. // "pageToken": {
  998. // "description": "nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.",
  999. // "location": "query",
  1000. // "type": "string"
  1001. // },
  1002. // "studentId": {
  1003. // "description": "Restricts returned courses to those having a student with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  1004. // "location": "query",
  1005. // "type": "string"
  1006. // },
  1007. // "teacherId": {
  1008. // "description": "Restricts returned courses to those having a teacher with the specified identifier. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  1009. // "location": "query",
  1010. // "type": "string"
  1011. // }
  1012. // },
  1013. // "path": "v1/courses",
  1014. // "response": {
  1015. // "$ref": "ListCoursesResponse"
  1016. // },
  1017. // "scopes": [
  1018. // "https://www.googleapis.com/auth/classroom.courses",
  1019. // "https://www.googleapis.com/auth/classroom.courses.readonly"
  1020. // ]
  1021. // }
  1022. }
  1023. // Pages invokes f for each page of results.
  1024. // A non-nil error returned from f will halt the iteration.
  1025. // The provided context supersedes any context provided to the Context method.
  1026. func (c *CoursesListCall) Pages(ctx context.Context, f func(*ListCoursesResponse) error) error {
  1027. c.ctx_ = ctx
  1028. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1029. for {
  1030. x, err := c.Do()
  1031. if err != nil {
  1032. return err
  1033. }
  1034. if err := f(x); err != nil {
  1035. return err
  1036. }
  1037. if x.NextPageToken == "" {
  1038. return nil
  1039. }
  1040. c.PageToken(x.NextPageToken)
  1041. }
  1042. }
  1043. // method id "classroom.courses.patch":
  1044. type CoursesPatchCall struct {
  1045. s *Service
  1046. id string
  1047. course *Course
  1048. urlParams_ gensupport.URLParams
  1049. ctx_ context.Context
  1050. }
  1051. // Patch: Updates one or more fields in a course. This method returns
  1052. // the following error codes: * `PERMISSION_DENIED` if the requesting
  1053. // user is not permitted to modify the requested course or for access
  1054. // errors. * `NOT_FOUND` if no course exists with the requested ID. *
  1055. // `INVALID_ARGUMENT` if invalid fields are specified in the update mask
  1056. // or if no update mask is supplied. * `FAILED_PRECONDITION` for the
  1057. // following request errors: * CourseNotModifiable
  1058. func (r *CoursesService) Patch(id string, course *Course) *CoursesPatchCall {
  1059. c := &CoursesPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1060. c.id = id
  1061. c.course = course
  1062. return c
  1063. }
  1064. // UpdateMask sets the optional parameter "updateMask": Mask that
  1065. // identifies which fields on the course to update. This field is
  1066. // required to do an update. The update will fail if invalid fields are
  1067. // specified. The following fields are valid: * `name` * `section` *
  1068. // `descriptionHeading` * `description` * `room` * `courseState` When
  1069. // set in a query parameter, this field should be specified as
  1070. // `updateMask=,,...`
  1071. func (c *CoursesPatchCall) UpdateMask(updateMask string) *CoursesPatchCall {
  1072. c.urlParams_.Set("updateMask", updateMask)
  1073. return c
  1074. }
  1075. // Fields allows partial responses to be retrieved. See
  1076. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1077. // for more information.
  1078. func (c *CoursesPatchCall) Fields(s ...googleapi.Field) *CoursesPatchCall {
  1079. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1080. return c
  1081. }
  1082. // Context sets the context to be used in this call's Do method. Any
  1083. // pending HTTP request will be aborted if the provided context is
  1084. // canceled.
  1085. func (c *CoursesPatchCall) Context(ctx context.Context) *CoursesPatchCall {
  1086. c.ctx_ = ctx
  1087. return c
  1088. }
  1089. func (c *CoursesPatchCall) doRequest(alt string) (*http.Response, error) {
  1090. var body io.Reader = nil
  1091. body, err := googleapi.WithoutDataWrapper.JSONReader(c.course)
  1092. if err != nil {
  1093. return nil, err
  1094. }
  1095. ctype := "application/json"
  1096. c.urlParams_.Set("alt", alt)
  1097. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{id}")
  1098. urls += "?" + c.urlParams_.Encode()
  1099. req, _ := http.NewRequest("PATCH", urls, body)
  1100. googleapi.Expand(req.URL, map[string]string{
  1101. "id": c.id,
  1102. })
  1103. req.Header.Set("Content-Type", ctype)
  1104. req.Header.Set("User-Agent", c.s.userAgent())
  1105. if c.ctx_ != nil {
  1106. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1107. }
  1108. return c.s.client.Do(req)
  1109. }
  1110. // Do executes the "classroom.courses.patch" call.
  1111. // Exactly one of *Course or error will be non-nil. Any non-2xx status
  1112. // code is an error. Response headers are in either
  1113. // *Course.ServerResponse.Header or (if a response was returned at all)
  1114. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1115. // check whether the returned error was because http.StatusNotModified
  1116. // was returned.
  1117. func (c *CoursesPatchCall) Do(opts ...googleapi.CallOption) (*Course, error) {
  1118. gensupport.SetOptions(c.urlParams_, opts...)
  1119. res, err := c.doRequest("json")
  1120. if res != nil && res.StatusCode == http.StatusNotModified {
  1121. if res.Body != nil {
  1122. res.Body.Close()
  1123. }
  1124. return nil, &googleapi.Error{
  1125. Code: res.StatusCode,
  1126. Header: res.Header,
  1127. }
  1128. }
  1129. if err != nil {
  1130. return nil, err
  1131. }
  1132. defer googleapi.CloseBody(res)
  1133. if err := googleapi.CheckResponse(res); err != nil {
  1134. return nil, err
  1135. }
  1136. ret := &Course{
  1137. ServerResponse: googleapi.ServerResponse{
  1138. Header: res.Header,
  1139. HTTPStatusCode: res.StatusCode,
  1140. },
  1141. }
  1142. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1143. return nil, err
  1144. }
  1145. return ret, nil
  1146. // {
  1147. // "description": "Updates one or more fields in a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `INVALID_ARGUMENT` if invalid fields are specified in the update mask or if no update mask is supplied. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable",
  1148. // "httpMethod": "PATCH",
  1149. // "id": "classroom.courses.patch",
  1150. // "parameterOrder": [
  1151. // "id"
  1152. // ],
  1153. // "parameters": {
  1154. // "id": {
  1155. // "description": "Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias.",
  1156. // "location": "path",
  1157. // "required": true,
  1158. // "type": "string"
  1159. // },
  1160. // "updateMask": {
  1161. // "description": "Mask that identifies which fields on the course to update. This field is required to do an update. The update will fail if invalid fields are specified. The following fields are valid: * `name` * `section` * `descriptionHeading` * `description` * `room` * `courseState` When set in a query parameter, this field should be specified as `updateMask=,,...`",
  1162. // "location": "query",
  1163. // "type": "string"
  1164. // }
  1165. // },
  1166. // "path": "v1/courses/{id}",
  1167. // "request": {
  1168. // "$ref": "Course"
  1169. // },
  1170. // "response": {
  1171. // "$ref": "Course"
  1172. // },
  1173. // "scopes": [
  1174. // "https://www.googleapis.com/auth/classroom.courses"
  1175. // ]
  1176. // }
  1177. }
  1178. // method id "classroom.courses.update":
  1179. type CoursesUpdateCall struct {
  1180. s *Service
  1181. id string
  1182. course *Course
  1183. urlParams_ gensupport.URLParams
  1184. ctx_ context.Context
  1185. }
  1186. // Update: Updates a course. This method returns the following error
  1187. // codes: * `PERMISSION_DENIED` if the requesting user is not permitted
  1188. // to modify the requested course or for access errors. * `NOT_FOUND` if
  1189. // no course exists with the requested ID. * `FAILED_PRECONDITION` for
  1190. // the following request errors: * CourseNotModifiable
  1191. func (r *CoursesService) Update(id string, course *Course) *CoursesUpdateCall {
  1192. c := &CoursesUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1193. c.id = id
  1194. c.course = course
  1195. return c
  1196. }
  1197. // Fields allows partial responses to be retrieved. See
  1198. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1199. // for more information.
  1200. func (c *CoursesUpdateCall) Fields(s ...googleapi.Field) *CoursesUpdateCall {
  1201. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1202. return c
  1203. }
  1204. // Context sets the context to be used in this call's Do method. Any
  1205. // pending HTTP request will be aborted if the provided context is
  1206. // canceled.
  1207. func (c *CoursesUpdateCall) Context(ctx context.Context) *CoursesUpdateCall {
  1208. c.ctx_ = ctx
  1209. return c
  1210. }
  1211. func (c *CoursesUpdateCall) doRequest(alt string) (*http.Response, error) {
  1212. var body io.Reader = nil
  1213. body, err := googleapi.WithoutDataWrapper.JSONReader(c.course)
  1214. if err != nil {
  1215. return nil, err
  1216. }
  1217. ctype := "application/json"
  1218. c.urlParams_.Set("alt", alt)
  1219. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{id}")
  1220. urls += "?" + c.urlParams_.Encode()
  1221. req, _ := http.NewRequest("PUT", urls, body)
  1222. googleapi.Expand(req.URL, map[string]string{
  1223. "id": c.id,
  1224. })
  1225. req.Header.Set("Content-Type", ctype)
  1226. req.Header.Set("User-Agent", c.s.userAgent())
  1227. if c.ctx_ != nil {
  1228. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1229. }
  1230. return c.s.client.Do(req)
  1231. }
  1232. // Do executes the "classroom.courses.update" call.
  1233. // Exactly one of *Course or error will be non-nil. Any non-2xx status
  1234. // code is an error. Response headers are in either
  1235. // *Course.ServerResponse.Header or (if a response was returned at all)
  1236. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1237. // check whether the returned error was because http.StatusNotModified
  1238. // was returned.
  1239. func (c *CoursesUpdateCall) Do(opts ...googleapi.CallOption) (*Course, error) {
  1240. gensupport.SetOptions(c.urlParams_, opts...)
  1241. res, err := c.doRequest("json")
  1242. if res != nil && res.StatusCode == http.StatusNotModified {
  1243. if res.Body != nil {
  1244. res.Body.Close()
  1245. }
  1246. return nil, &googleapi.Error{
  1247. Code: res.StatusCode,
  1248. Header: res.Header,
  1249. }
  1250. }
  1251. if err != nil {
  1252. return nil, err
  1253. }
  1254. defer googleapi.CloseBody(res)
  1255. if err := googleapi.CheckResponse(res); err != nil {
  1256. return nil, err
  1257. }
  1258. ret := &Course{
  1259. ServerResponse: googleapi.ServerResponse{
  1260. Header: res.Header,
  1261. HTTPStatusCode: res.StatusCode,
  1262. },
  1263. }
  1264. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1265. return nil, err
  1266. }
  1267. return ret, nil
  1268. // {
  1269. // "description": "Updates a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to modify the requested course or for access errors. * `NOT_FOUND` if no course exists with the requested ID. * `FAILED_PRECONDITION` for the following request errors: * CourseNotModifiable",
  1270. // "httpMethod": "PUT",
  1271. // "id": "classroom.courses.update",
  1272. // "parameterOrder": [
  1273. // "id"
  1274. // ],
  1275. // "parameters": {
  1276. // "id": {
  1277. // "description": "Identifier of the course to update. This identifier can be either the Classroom-assigned identifier or an alias.",
  1278. // "location": "path",
  1279. // "required": true,
  1280. // "type": "string"
  1281. // }
  1282. // },
  1283. // "path": "v1/courses/{id}",
  1284. // "request": {
  1285. // "$ref": "Course"
  1286. // },
  1287. // "response": {
  1288. // "$ref": "Course"
  1289. // },
  1290. // "scopes": [
  1291. // "https://www.googleapis.com/auth/classroom.courses"
  1292. // ]
  1293. // }
  1294. }
  1295. // method id "classroom.courses.aliases.create":
  1296. type CoursesAliasesCreateCall struct {
  1297. s *Service
  1298. courseId string
  1299. coursealias *CourseAlias
  1300. urlParams_ gensupport.URLParams
  1301. ctx_ context.Context
  1302. }
  1303. // Create: Creates an alias for a course. This method returns the
  1304. // following error codes: * `PERMISSION_DENIED` if the requesting user
  1305. // is not permitted to create the alias or for access errors. *
  1306. // `NOT_FOUND` if the course does not exist. * `ALREADY_EXISTS` if the
  1307. // alias already exists.
  1308. func (r *CoursesAliasesService) Create(courseId string, coursealias *CourseAlias) *CoursesAliasesCreateCall {
  1309. c := &CoursesAliasesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1310. c.courseId = courseId
  1311. c.coursealias = coursealias
  1312. return c
  1313. }
  1314. // Fields allows partial responses to be retrieved. See
  1315. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1316. // for more information.
  1317. func (c *CoursesAliasesCreateCall) Fields(s ...googleapi.Field) *CoursesAliasesCreateCall {
  1318. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1319. return c
  1320. }
  1321. // Context sets the context to be used in this call's Do method. Any
  1322. // pending HTTP request will be aborted if the provided context is
  1323. // canceled.
  1324. func (c *CoursesAliasesCreateCall) Context(ctx context.Context) *CoursesAliasesCreateCall {
  1325. c.ctx_ = ctx
  1326. return c
  1327. }
  1328. func (c *CoursesAliasesCreateCall) doRequest(alt string) (*http.Response, error) {
  1329. var body io.Reader = nil
  1330. body, err := googleapi.WithoutDataWrapper.JSONReader(c.coursealias)
  1331. if err != nil {
  1332. return nil, err
  1333. }
  1334. ctype := "application/json"
  1335. c.urlParams_.Set("alt", alt)
  1336. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/aliases")
  1337. urls += "?" + c.urlParams_.Encode()
  1338. req, _ := http.NewRequest("POST", urls, body)
  1339. googleapi.Expand(req.URL, map[string]string{
  1340. "courseId": c.courseId,
  1341. })
  1342. req.Header.Set("Content-Type", ctype)
  1343. req.Header.Set("User-Agent", c.s.userAgent())
  1344. if c.ctx_ != nil {
  1345. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1346. }
  1347. return c.s.client.Do(req)
  1348. }
  1349. // Do executes the "classroom.courses.aliases.create" call.
  1350. // Exactly one of *CourseAlias or error will be non-nil. Any non-2xx
  1351. // status code is an error. Response headers are in either
  1352. // *CourseAlias.ServerResponse.Header or (if a response was returned at
  1353. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1354. // to check whether the returned error was because
  1355. // http.StatusNotModified was returned.
  1356. func (c *CoursesAliasesCreateCall) Do(opts ...googleapi.CallOption) (*CourseAlias, error) {
  1357. gensupport.SetOptions(c.urlParams_, opts...)
  1358. res, err := c.doRequest("json")
  1359. if res != nil && res.StatusCode == http.StatusNotModified {
  1360. if res.Body != nil {
  1361. res.Body.Close()
  1362. }
  1363. return nil, &googleapi.Error{
  1364. Code: res.StatusCode,
  1365. Header: res.Header,
  1366. }
  1367. }
  1368. if err != nil {
  1369. return nil, err
  1370. }
  1371. defer googleapi.CloseBody(res)
  1372. if err := googleapi.CheckResponse(res); err != nil {
  1373. return nil, err
  1374. }
  1375. ret := &CourseAlias{
  1376. ServerResponse: googleapi.ServerResponse{
  1377. Header: res.Header,
  1378. HTTPStatusCode: res.StatusCode,
  1379. },
  1380. }
  1381. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1382. return nil, err
  1383. }
  1384. return ret, nil
  1385. // {
  1386. // "description": "Creates an alias for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create the alias or for access errors. * `NOT_FOUND` if the course does not exist. * `ALREADY_EXISTS` if the alias already exists.",
  1387. // "httpMethod": "POST",
  1388. // "id": "classroom.courses.aliases.create",
  1389. // "parameterOrder": [
  1390. // "courseId"
  1391. // ],
  1392. // "parameters": {
  1393. // "courseId": {
  1394. // "description": "Identifier of the course to alias. This identifier can be either the Classroom-assigned identifier or an alias.",
  1395. // "location": "path",
  1396. // "required": true,
  1397. // "type": "string"
  1398. // }
  1399. // },
  1400. // "path": "v1/courses/{courseId}/aliases",
  1401. // "request": {
  1402. // "$ref": "CourseAlias"
  1403. // },
  1404. // "response": {
  1405. // "$ref": "CourseAlias"
  1406. // },
  1407. // "scopes": [
  1408. // "https://www.googleapis.com/auth/classroom.courses"
  1409. // ]
  1410. // }
  1411. }
  1412. // method id "classroom.courses.aliases.delete":
  1413. type CoursesAliasesDeleteCall struct {
  1414. s *Service
  1415. courseId string
  1416. aliasid string
  1417. urlParams_ gensupport.URLParams
  1418. ctx_ context.Context
  1419. }
  1420. // Delete: Deletes an alias of a course. This method returns the
  1421. // following error codes: * `PERMISSION_DENIED` if the requesting user
  1422. // is not permitted to remove the alias or for access errors. *
  1423. // `NOT_FOUND` if the alias does not exist.
  1424. func (r *CoursesAliasesService) Delete(courseId string, aliasid string) *CoursesAliasesDeleteCall {
  1425. c := &CoursesAliasesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1426. c.courseId = courseId
  1427. c.aliasid = aliasid
  1428. return c
  1429. }
  1430. // Fields allows partial responses to be retrieved. See
  1431. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1432. // for more information.
  1433. func (c *CoursesAliasesDeleteCall) Fields(s ...googleapi.Field) *CoursesAliasesDeleteCall {
  1434. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1435. return c
  1436. }
  1437. // Context sets the context to be used in this call's Do method. Any
  1438. // pending HTTP request will be aborted if the provided context is
  1439. // canceled.
  1440. func (c *CoursesAliasesDeleteCall) Context(ctx context.Context) *CoursesAliasesDeleteCall {
  1441. c.ctx_ = ctx
  1442. return c
  1443. }
  1444. func (c *CoursesAliasesDeleteCall) doRequest(alt string) (*http.Response, error) {
  1445. var body io.Reader = nil
  1446. c.urlParams_.Set("alt", alt)
  1447. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/aliases/{alias}")
  1448. urls += "?" + c.urlParams_.Encode()
  1449. req, _ := http.NewRequest("DELETE", urls, body)
  1450. googleapi.Expand(req.URL, map[string]string{
  1451. "courseId": c.courseId,
  1452. "alias": c.aliasid,
  1453. })
  1454. req.Header.Set("User-Agent", c.s.userAgent())
  1455. if c.ctx_ != nil {
  1456. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1457. }
  1458. return c.s.client.Do(req)
  1459. }
  1460. // Do executes the "classroom.courses.aliases.delete" call.
  1461. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1462. // code is an error. Response headers are in either
  1463. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1464. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1465. // check whether the returned error was because http.StatusNotModified
  1466. // was returned.
  1467. func (c *CoursesAliasesDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1468. gensupport.SetOptions(c.urlParams_, opts...)
  1469. res, err := c.doRequest("json")
  1470. if res != nil && res.StatusCode == http.StatusNotModified {
  1471. if res.Body != nil {
  1472. res.Body.Close()
  1473. }
  1474. return nil, &googleapi.Error{
  1475. Code: res.StatusCode,
  1476. Header: res.Header,
  1477. }
  1478. }
  1479. if err != nil {
  1480. return nil, err
  1481. }
  1482. defer googleapi.CloseBody(res)
  1483. if err := googleapi.CheckResponse(res); err != nil {
  1484. return nil, err
  1485. }
  1486. ret := &Empty{
  1487. ServerResponse: googleapi.ServerResponse{
  1488. Header: res.Header,
  1489. HTTPStatusCode: res.StatusCode,
  1490. },
  1491. }
  1492. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1493. return nil, err
  1494. }
  1495. return ret, nil
  1496. // {
  1497. // "description": "Deletes an alias of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to remove the alias or for access errors. * `NOT_FOUND` if the alias does not exist.",
  1498. // "httpMethod": "DELETE",
  1499. // "id": "classroom.courses.aliases.delete",
  1500. // "parameterOrder": [
  1501. // "courseId",
  1502. // "alias"
  1503. // ],
  1504. // "parameters": {
  1505. // "alias": {
  1506. // "description": "Alias to delete. This may not be the Classroom-assigned identifier.",
  1507. // "location": "path",
  1508. // "required": true,
  1509. // "type": "string"
  1510. // },
  1511. // "courseId": {
  1512. // "description": "Identifier of the course whose alias should be deleted. This identifier can be either the Classroom-assigned identifier or an alias.",
  1513. // "location": "path",
  1514. // "required": true,
  1515. // "type": "string"
  1516. // }
  1517. // },
  1518. // "path": "v1/courses/{courseId}/aliases/{alias}",
  1519. // "response": {
  1520. // "$ref": "Empty"
  1521. // },
  1522. // "scopes": [
  1523. // "https://www.googleapis.com/auth/classroom.courses"
  1524. // ]
  1525. // }
  1526. }
  1527. // method id "classroom.courses.aliases.list":
  1528. type CoursesAliasesListCall struct {
  1529. s *Service
  1530. courseId string
  1531. urlParams_ gensupport.URLParams
  1532. ifNoneMatch_ string
  1533. ctx_ context.Context
  1534. }
  1535. // List: Returns a list of aliases for a course. This method returns the
  1536. // following error codes: * `PERMISSION_DENIED` if the requesting user
  1537. // is not permitted to access the course or for access errors. *
  1538. // `NOT_FOUND` if the course does not exist.
  1539. func (r *CoursesAliasesService) List(courseId string) *CoursesAliasesListCall {
  1540. c := &CoursesAliasesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1541. c.courseId = courseId
  1542. return c
  1543. }
  1544. // PageSize sets the optional parameter "pageSize": Maximum number of
  1545. // items to return. Zero or unspecified indicates that the server may
  1546. // assign a maximum. The server may return fewer than the specified
  1547. // number of results.
  1548. func (c *CoursesAliasesListCall) PageSize(pageSize int64) *CoursesAliasesListCall {
  1549. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1550. return c
  1551. }
  1552. // PageToken sets the optional parameter "pageToken": nextPageToken
  1553. // value returned from a previous list call, indicating that the
  1554. // subsequent page of results should be returned. The list request must
  1555. // be otherwise identical to the one that resulted in this token.
  1556. func (c *CoursesAliasesListCall) PageToken(pageToken string) *CoursesAliasesListCall {
  1557. c.urlParams_.Set("pageToken", pageToken)
  1558. return c
  1559. }
  1560. // Fields allows partial responses to be retrieved. See
  1561. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1562. // for more information.
  1563. func (c *CoursesAliasesListCall) Fields(s ...googleapi.Field) *CoursesAliasesListCall {
  1564. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1565. return c
  1566. }
  1567. // IfNoneMatch sets the optional parameter which makes the operation
  1568. // fail if the object's ETag matches the given value. This is useful for
  1569. // getting updates only after the object has changed since the last
  1570. // request. Use googleapi.IsNotModified to check whether the response
  1571. // error from Do is the result of In-None-Match.
  1572. func (c *CoursesAliasesListCall) IfNoneMatch(entityTag string) *CoursesAliasesListCall {
  1573. c.ifNoneMatch_ = entityTag
  1574. return c
  1575. }
  1576. // Context sets the context to be used in this call's Do method. Any
  1577. // pending HTTP request will be aborted if the provided context is
  1578. // canceled.
  1579. func (c *CoursesAliasesListCall) Context(ctx context.Context) *CoursesAliasesListCall {
  1580. c.ctx_ = ctx
  1581. return c
  1582. }
  1583. func (c *CoursesAliasesListCall) doRequest(alt string) (*http.Response, error) {
  1584. var body io.Reader = nil
  1585. c.urlParams_.Set("alt", alt)
  1586. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/aliases")
  1587. urls += "?" + c.urlParams_.Encode()
  1588. req, _ := http.NewRequest("GET", urls, body)
  1589. googleapi.Expand(req.URL, map[string]string{
  1590. "courseId": c.courseId,
  1591. })
  1592. req.Header.Set("User-Agent", c.s.userAgent())
  1593. if c.ifNoneMatch_ != "" {
  1594. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1595. }
  1596. if c.ctx_ != nil {
  1597. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1598. }
  1599. return c.s.client.Do(req)
  1600. }
  1601. // Do executes the "classroom.courses.aliases.list" call.
  1602. // Exactly one of *ListCourseAliasesResponse or error will be non-nil.
  1603. // Any non-2xx status code is an error. Response headers are in either
  1604. // *ListCourseAliasesResponse.ServerResponse.Header or (if a response
  1605. // was returned at all) in error.(*googleapi.Error).Header. Use
  1606. // googleapi.IsNotModified to check whether the returned error was
  1607. // because http.StatusNotModified was returned.
  1608. func (c *CoursesAliasesListCall) Do(opts ...googleapi.CallOption) (*ListCourseAliasesResponse, error) {
  1609. gensupport.SetOptions(c.urlParams_, opts...)
  1610. res, err := c.doRequest("json")
  1611. if res != nil && res.StatusCode == http.StatusNotModified {
  1612. if res.Body != nil {
  1613. res.Body.Close()
  1614. }
  1615. return nil, &googleapi.Error{
  1616. Code: res.StatusCode,
  1617. Header: res.Header,
  1618. }
  1619. }
  1620. if err != nil {
  1621. return nil, err
  1622. }
  1623. defer googleapi.CloseBody(res)
  1624. if err := googleapi.CheckResponse(res); err != nil {
  1625. return nil, err
  1626. }
  1627. ret := &ListCourseAliasesResponse{
  1628. ServerResponse: googleapi.ServerResponse{
  1629. Header: res.Header,
  1630. HTTPStatusCode: res.StatusCode,
  1631. },
  1632. }
  1633. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1634. return nil, err
  1635. }
  1636. return ret, nil
  1637. // {
  1638. // "description": "Returns a list of aliases for a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access the course or for access errors. * `NOT_FOUND` if the course does not exist.",
  1639. // "httpMethod": "GET",
  1640. // "id": "classroom.courses.aliases.list",
  1641. // "parameterOrder": [
  1642. // "courseId"
  1643. // ],
  1644. // "parameters": {
  1645. // "courseId": {
  1646. // "description": "The identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  1647. // "location": "path",
  1648. // "required": true,
  1649. // "type": "string"
  1650. // },
  1651. // "pageSize": {
  1652. // "description": "Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum. The server may return fewer than the specified number of results.",
  1653. // "format": "int32",
  1654. // "location": "query",
  1655. // "type": "integer"
  1656. // },
  1657. // "pageToken": {
  1658. // "description": "nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.",
  1659. // "location": "query",
  1660. // "type": "string"
  1661. // }
  1662. // },
  1663. // "path": "v1/courses/{courseId}/aliases",
  1664. // "response": {
  1665. // "$ref": "ListCourseAliasesResponse"
  1666. // },
  1667. // "scopes": [
  1668. // "https://www.googleapis.com/auth/classroom.courses",
  1669. // "https://www.googleapis.com/auth/classroom.courses.readonly"
  1670. // ]
  1671. // }
  1672. }
  1673. // Pages invokes f for each page of results.
  1674. // A non-nil error returned from f will halt the iteration.
  1675. // The provided context supersedes any context provided to the Context method.
  1676. func (c *CoursesAliasesListCall) Pages(ctx context.Context, f func(*ListCourseAliasesResponse) error) error {
  1677. c.ctx_ = ctx
  1678. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1679. for {
  1680. x, err := c.Do()
  1681. if err != nil {
  1682. return err
  1683. }
  1684. if err := f(x); err != nil {
  1685. return err
  1686. }
  1687. if x.NextPageToken == "" {
  1688. return nil
  1689. }
  1690. c.PageToken(x.NextPageToken)
  1691. }
  1692. }
  1693. // method id "classroom.courses.students.create":
  1694. type CoursesStudentsCreateCall struct {
  1695. s *Service
  1696. courseId string
  1697. student *Student
  1698. urlParams_ gensupport.URLParams
  1699. ctx_ context.Context
  1700. }
  1701. // Create: Adds a user as a student of a course. This method returns the
  1702. // following error codes: * `PERMISSION_DENIED` if the requesting user
  1703. // is not permitted to create students in this course or for access
  1704. // errors. * `NOT_FOUND` if the requested course ID does not exist. *
  1705. // `FAILED_PRECONDITION` if the requested user's account is disabled,
  1706. // for the following request errors: * CourseMemberLimitReached *
  1707. // CourseNotModifiable * UserGroupsMembershipLimitReached *
  1708. // `ALREADY_EXISTS` if the user is already a student or teacher in the
  1709. // course.
  1710. func (r *CoursesStudentsService) Create(courseId string, student *Student) *CoursesStudentsCreateCall {
  1711. c := &CoursesStudentsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1712. c.courseId = courseId
  1713. c.student = student
  1714. return c
  1715. }
  1716. // EnrollmentCode sets the optional parameter "enrollmentCode":
  1717. // Enrollment code of the course to create the student in. This code is
  1718. // required if userId corresponds to the requesting user; it may be
  1719. // omitted if the requesting user has administrative permissions to
  1720. // create students for any user.
  1721. func (c *CoursesStudentsCreateCall) EnrollmentCode(enrollmentCode string) *CoursesStudentsCreateCall {
  1722. c.urlParams_.Set("enrollmentCode", enrollmentCode)
  1723. return c
  1724. }
  1725. // Fields allows partial responses to be retrieved. See
  1726. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1727. // for more information.
  1728. func (c *CoursesStudentsCreateCall) Fields(s ...googleapi.Field) *CoursesStudentsCreateCall {
  1729. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1730. return c
  1731. }
  1732. // Context sets the context to be used in this call's Do method. Any
  1733. // pending HTTP request will be aborted if the provided context is
  1734. // canceled.
  1735. func (c *CoursesStudentsCreateCall) Context(ctx context.Context) *CoursesStudentsCreateCall {
  1736. c.ctx_ = ctx
  1737. return c
  1738. }
  1739. func (c *CoursesStudentsCreateCall) doRequest(alt string) (*http.Response, error) {
  1740. var body io.Reader = nil
  1741. body, err := googleapi.WithoutDataWrapper.JSONReader(c.student)
  1742. if err != nil {
  1743. return nil, err
  1744. }
  1745. ctype := "application/json"
  1746. c.urlParams_.Set("alt", alt)
  1747. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/students")
  1748. urls += "?" + c.urlParams_.Encode()
  1749. req, _ := http.NewRequest("POST", urls, body)
  1750. googleapi.Expand(req.URL, map[string]string{
  1751. "courseId": c.courseId,
  1752. })
  1753. req.Header.Set("Content-Type", ctype)
  1754. req.Header.Set("User-Agent", c.s.userAgent())
  1755. if c.ctx_ != nil {
  1756. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1757. }
  1758. return c.s.client.Do(req)
  1759. }
  1760. // Do executes the "classroom.courses.students.create" call.
  1761. // Exactly one of *Student or error will be non-nil. Any non-2xx status
  1762. // code is an error. Response headers are in either
  1763. // *Student.ServerResponse.Header or (if a response was returned at all)
  1764. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1765. // check whether the returned error was because http.StatusNotModified
  1766. // was returned.
  1767. func (c *CoursesStudentsCreateCall) Do(opts ...googleapi.CallOption) (*Student, error) {
  1768. gensupport.SetOptions(c.urlParams_, opts...)
  1769. res, err := c.doRequest("json")
  1770. if res != nil && res.StatusCode == http.StatusNotModified {
  1771. if res.Body != nil {
  1772. res.Body.Close()
  1773. }
  1774. return nil, &googleapi.Error{
  1775. Code: res.StatusCode,
  1776. Header: res.Header,
  1777. }
  1778. }
  1779. if err != nil {
  1780. return nil, err
  1781. }
  1782. defer googleapi.CloseBody(res)
  1783. if err := googleapi.CheckResponse(res); err != nil {
  1784. return nil, err
  1785. }
  1786. ret := &Student{
  1787. ServerResponse: googleapi.ServerResponse{
  1788. Header: res.Header,
  1789. HTTPStatusCode: res.StatusCode,
  1790. },
  1791. }
  1792. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1793. return nil, err
  1794. }
  1795. return ret, nil
  1796. // {
  1797. // "description": "Adds a user as a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create students in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if the user is already a student or teacher in the course.",
  1798. // "httpMethod": "POST",
  1799. // "id": "classroom.courses.students.create",
  1800. // "parameterOrder": [
  1801. // "courseId"
  1802. // ],
  1803. // "parameters": {
  1804. // "courseId": {
  1805. // "description": "Identifier of the course to create the student in. This identifier can be either the Classroom-assigned identifier or an alias.",
  1806. // "location": "path",
  1807. // "required": true,
  1808. // "type": "string"
  1809. // },
  1810. // "enrollmentCode": {
  1811. // "description": "Enrollment code of the course to create the student in. This code is required if userId corresponds to the requesting user; it may be omitted if the requesting user has administrative permissions to create students for any user.",
  1812. // "location": "query",
  1813. // "type": "string"
  1814. // }
  1815. // },
  1816. // "path": "v1/courses/{courseId}/students",
  1817. // "request": {
  1818. // "$ref": "Student"
  1819. // },
  1820. // "response": {
  1821. // "$ref": "Student"
  1822. // },
  1823. // "scopes": [
  1824. // "https://www.googleapis.com/auth/classroom.profile.emails",
  1825. // "https://www.googleapis.com/auth/classroom.profile.photos",
  1826. // "https://www.googleapis.com/auth/classroom.rosters"
  1827. // ]
  1828. // }
  1829. }
  1830. // method id "classroom.courses.students.delete":
  1831. type CoursesStudentsDeleteCall struct {
  1832. s *Service
  1833. courseId string
  1834. userId string
  1835. urlParams_ gensupport.URLParams
  1836. ctx_ context.Context
  1837. }
  1838. // Delete: Deletes a student of a course. This method returns the
  1839. // following error codes: * `PERMISSION_DENIED` if the requesting user
  1840. // is not permitted to delete students of this course or for access
  1841. // errors. * `NOT_FOUND` if no student of this course has the requested
  1842. // ID or if the course does not exist.
  1843. func (r *CoursesStudentsService) Delete(courseId string, userId string) *CoursesStudentsDeleteCall {
  1844. c := &CoursesStudentsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1845. c.courseId = courseId
  1846. c.userId = userId
  1847. return c
  1848. }
  1849. // Fields allows partial responses to be retrieved. See
  1850. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1851. // for more information.
  1852. func (c *CoursesStudentsDeleteCall) Fields(s ...googleapi.Field) *CoursesStudentsDeleteCall {
  1853. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1854. return c
  1855. }
  1856. // Context sets the context to be used in this call's Do method. Any
  1857. // pending HTTP request will be aborted if the provided context is
  1858. // canceled.
  1859. func (c *CoursesStudentsDeleteCall) Context(ctx context.Context) *CoursesStudentsDeleteCall {
  1860. c.ctx_ = ctx
  1861. return c
  1862. }
  1863. func (c *CoursesStudentsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1864. var body io.Reader = nil
  1865. c.urlParams_.Set("alt", alt)
  1866. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/students/{userId}")
  1867. urls += "?" + c.urlParams_.Encode()
  1868. req, _ := http.NewRequest("DELETE", urls, body)
  1869. googleapi.Expand(req.URL, map[string]string{
  1870. "courseId": c.courseId,
  1871. "userId": c.userId,
  1872. })
  1873. req.Header.Set("User-Agent", c.s.userAgent())
  1874. if c.ctx_ != nil {
  1875. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1876. }
  1877. return c.s.client.Do(req)
  1878. }
  1879. // Do executes the "classroom.courses.students.delete" call.
  1880. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1881. // code is an error. Response headers are in either
  1882. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1883. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1884. // check whether the returned error was because http.StatusNotModified
  1885. // was returned.
  1886. func (c *CoursesStudentsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1887. gensupport.SetOptions(c.urlParams_, opts...)
  1888. res, err := c.doRequest("json")
  1889. if res != nil && res.StatusCode == http.StatusNotModified {
  1890. if res.Body != nil {
  1891. res.Body.Close()
  1892. }
  1893. return nil, &googleapi.Error{
  1894. Code: res.StatusCode,
  1895. Header: res.Header,
  1896. }
  1897. }
  1898. if err != nil {
  1899. return nil, err
  1900. }
  1901. defer googleapi.CloseBody(res)
  1902. if err := googleapi.CheckResponse(res); err != nil {
  1903. return nil, err
  1904. }
  1905. ret := &Empty{
  1906. ServerResponse: googleapi.ServerResponse{
  1907. Header: res.Header,
  1908. HTTPStatusCode: res.StatusCode,
  1909. },
  1910. }
  1911. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1912. return nil, err
  1913. }
  1914. return ret, nil
  1915. // {
  1916. // "description": "Deletes a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist.",
  1917. // "httpMethod": "DELETE",
  1918. // "id": "classroom.courses.students.delete",
  1919. // "parameterOrder": [
  1920. // "courseId",
  1921. // "userId"
  1922. // ],
  1923. // "parameters": {
  1924. // "courseId": {
  1925. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  1926. // "location": "path",
  1927. // "required": true,
  1928. // "type": "string"
  1929. // },
  1930. // "userId": {
  1931. // "description": "Identifier of the student to delete. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  1932. // "location": "path",
  1933. // "required": true,
  1934. // "type": "string"
  1935. // }
  1936. // },
  1937. // "path": "v1/courses/{courseId}/students/{userId}",
  1938. // "response": {
  1939. // "$ref": "Empty"
  1940. // },
  1941. // "scopes": [
  1942. // "https://www.googleapis.com/auth/classroom.rosters"
  1943. // ]
  1944. // }
  1945. }
  1946. // method id "classroom.courses.students.get":
  1947. type CoursesStudentsGetCall struct {
  1948. s *Service
  1949. courseId string
  1950. userId string
  1951. urlParams_ gensupport.URLParams
  1952. ifNoneMatch_ string
  1953. ctx_ context.Context
  1954. }
  1955. // Get: Returns a student of a course. This method returns the following
  1956. // error codes: * `PERMISSION_DENIED` if the requesting user is not
  1957. // permitted to view students of this course or for access errors. *
  1958. // `NOT_FOUND` if no student of this course has the requested ID or if
  1959. // the course does not exist.
  1960. func (r *CoursesStudentsService) Get(courseId string, userId string) *CoursesStudentsGetCall {
  1961. c := &CoursesStudentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1962. c.courseId = courseId
  1963. c.userId = userId
  1964. return c
  1965. }
  1966. // Fields allows partial responses to be retrieved. See
  1967. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1968. // for more information.
  1969. func (c *CoursesStudentsGetCall) Fields(s ...googleapi.Field) *CoursesStudentsGetCall {
  1970. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1971. return c
  1972. }
  1973. // IfNoneMatch sets the optional parameter which makes the operation
  1974. // fail if the object's ETag matches the given value. This is useful for
  1975. // getting updates only after the object has changed since the last
  1976. // request. Use googleapi.IsNotModified to check whether the response
  1977. // error from Do is the result of In-None-Match.
  1978. func (c *CoursesStudentsGetCall) IfNoneMatch(entityTag string) *CoursesStudentsGetCall {
  1979. c.ifNoneMatch_ = entityTag
  1980. return c
  1981. }
  1982. // Context sets the context to be used in this call's Do method. Any
  1983. // pending HTTP request will be aborted if the provided context is
  1984. // canceled.
  1985. func (c *CoursesStudentsGetCall) Context(ctx context.Context) *CoursesStudentsGetCall {
  1986. c.ctx_ = ctx
  1987. return c
  1988. }
  1989. func (c *CoursesStudentsGetCall) doRequest(alt string) (*http.Response, error) {
  1990. var body io.Reader = nil
  1991. c.urlParams_.Set("alt", alt)
  1992. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/students/{userId}")
  1993. urls += "?" + c.urlParams_.Encode()
  1994. req, _ := http.NewRequest("GET", urls, body)
  1995. googleapi.Expand(req.URL, map[string]string{
  1996. "courseId": c.courseId,
  1997. "userId": c.userId,
  1998. })
  1999. req.Header.Set("User-Agent", c.s.userAgent())
  2000. if c.ifNoneMatch_ != "" {
  2001. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2002. }
  2003. if c.ctx_ != nil {
  2004. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2005. }
  2006. return c.s.client.Do(req)
  2007. }
  2008. // Do executes the "classroom.courses.students.get" call.
  2009. // Exactly one of *Student or error will be non-nil. Any non-2xx status
  2010. // code is an error. Response headers are in either
  2011. // *Student.ServerResponse.Header or (if a response was returned at all)
  2012. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2013. // check whether the returned error was because http.StatusNotModified
  2014. // was returned.
  2015. func (c *CoursesStudentsGetCall) Do(opts ...googleapi.CallOption) (*Student, error) {
  2016. gensupport.SetOptions(c.urlParams_, opts...)
  2017. res, err := c.doRequest("json")
  2018. if res != nil && res.StatusCode == http.StatusNotModified {
  2019. if res.Body != nil {
  2020. res.Body.Close()
  2021. }
  2022. return nil, &googleapi.Error{
  2023. Code: res.StatusCode,
  2024. Header: res.Header,
  2025. }
  2026. }
  2027. if err != nil {
  2028. return nil, err
  2029. }
  2030. defer googleapi.CloseBody(res)
  2031. if err := googleapi.CheckResponse(res); err != nil {
  2032. return nil, err
  2033. }
  2034. ret := &Student{
  2035. ServerResponse: googleapi.ServerResponse{
  2036. Header: res.Header,
  2037. HTTPStatusCode: res.StatusCode,
  2038. },
  2039. }
  2040. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2041. return nil, err
  2042. }
  2043. return ret, nil
  2044. // {
  2045. // "description": "Returns a student of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view students of this course or for access errors. * `NOT_FOUND` if no student of this course has the requested ID or if the course does not exist.",
  2046. // "httpMethod": "GET",
  2047. // "id": "classroom.courses.students.get",
  2048. // "parameterOrder": [
  2049. // "courseId",
  2050. // "userId"
  2051. // ],
  2052. // "parameters": {
  2053. // "courseId": {
  2054. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  2055. // "location": "path",
  2056. // "required": true,
  2057. // "type": "string"
  2058. // },
  2059. // "userId": {
  2060. // "description": "Identifier of the student to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  2061. // "location": "path",
  2062. // "required": true,
  2063. // "type": "string"
  2064. // }
  2065. // },
  2066. // "path": "v1/courses/{courseId}/students/{userId}",
  2067. // "response": {
  2068. // "$ref": "Student"
  2069. // },
  2070. // "scopes": [
  2071. // "https://www.googleapis.com/auth/classroom.profile.emails",
  2072. // "https://www.googleapis.com/auth/classroom.profile.photos",
  2073. // "https://www.googleapis.com/auth/classroom.rosters",
  2074. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  2075. // ]
  2076. // }
  2077. }
  2078. // method id "classroom.courses.students.list":
  2079. type CoursesStudentsListCall struct {
  2080. s *Service
  2081. courseId string
  2082. urlParams_ gensupport.URLParams
  2083. ifNoneMatch_ string
  2084. ctx_ context.Context
  2085. }
  2086. // List: Returns a list of students of this course that the requester is
  2087. // permitted to view. This method returns the following error codes: *
  2088. // `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for
  2089. // access errors.
  2090. func (r *CoursesStudentsService) List(courseId string) *CoursesStudentsListCall {
  2091. c := &CoursesStudentsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2092. c.courseId = courseId
  2093. return c
  2094. }
  2095. // PageSize sets the optional parameter "pageSize": Maximum number of
  2096. // items to return. Zero means no maximum. The server may return fewer
  2097. // than the specified number of results.
  2098. func (c *CoursesStudentsListCall) PageSize(pageSize int64) *CoursesStudentsListCall {
  2099. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  2100. return c
  2101. }
  2102. // PageToken sets the optional parameter "pageToken": nextPageToken
  2103. // value returned from a previous list call, indicating that the
  2104. // subsequent page of results should be returned. The list request must
  2105. // be otherwise identical to the one that resulted in this token.
  2106. func (c *CoursesStudentsListCall) PageToken(pageToken string) *CoursesStudentsListCall {
  2107. c.urlParams_.Set("pageToken", pageToken)
  2108. return c
  2109. }
  2110. // Fields allows partial responses to be retrieved. See
  2111. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2112. // for more information.
  2113. func (c *CoursesStudentsListCall) Fields(s ...googleapi.Field) *CoursesStudentsListCall {
  2114. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2115. return c
  2116. }
  2117. // IfNoneMatch sets the optional parameter which makes the operation
  2118. // fail if the object's ETag matches the given value. This is useful for
  2119. // getting updates only after the object has changed since the last
  2120. // request. Use googleapi.IsNotModified to check whether the response
  2121. // error from Do is the result of In-None-Match.
  2122. func (c *CoursesStudentsListCall) IfNoneMatch(entityTag string) *CoursesStudentsListCall {
  2123. c.ifNoneMatch_ = entityTag
  2124. return c
  2125. }
  2126. // Context sets the context to be used in this call's Do method. Any
  2127. // pending HTTP request will be aborted if the provided context is
  2128. // canceled.
  2129. func (c *CoursesStudentsListCall) Context(ctx context.Context) *CoursesStudentsListCall {
  2130. c.ctx_ = ctx
  2131. return c
  2132. }
  2133. func (c *CoursesStudentsListCall) doRequest(alt string) (*http.Response, error) {
  2134. var body io.Reader = nil
  2135. c.urlParams_.Set("alt", alt)
  2136. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/students")
  2137. urls += "?" + c.urlParams_.Encode()
  2138. req, _ := http.NewRequest("GET", urls, body)
  2139. googleapi.Expand(req.URL, map[string]string{
  2140. "courseId": c.courseId,
  2141. })
  2142. req.Header.Set("User-Agent", c.s.userAgent())
  2143. if c.ifNoneMatch_ != "" {
  2144. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2145. }
  2146. if c.ctx_ != nil {
  2147. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2148. }
  2149. return c.s.client.Do(req)
  2150. }
  2151. // Do executes the "classroom.courses.students.list" call.
  2152. // Exactly one of *ListStudentsResponse or error will be non-nil. Any
  2153. // non-2xx status code is an error. Response headers are in either
  2154. // *ListStudentsResponse.ServerResponse.Header or (if a response was
  2155. // returned at all) in error.(*googleapi.Error).Header. Use
  2156. // googleapi.IsNotModified to check whether the returned error was
  2157. // because http.StatusNotModified was returned.
  2158. func (c *CoursesStudentsListCall) Do(opts ...googleapi.CallOption) (*ListStudentsResponse, error) {
  2159. gensupport.SetOptions(c.urlParams_, opts...)
  2160. res, err := c.doRequest("json")
  2161. if res != nil && res.StatusCode == http.StatusNotModified {
  2162. if res.Body != nil {
  2163. res.Body.Close()
  2164. }
  2165. return nil, &googleapi.Error{
  2166. Code: res.StatusCode,
  2167. Header: res.Header,
  2168. }
  2169. }
  2170. if err != nil {
  2171. return nil, err
  2172. }
  2173. defer googleapi.CloseBody(res)
  2174. if err := googleapi.CheckResponse(res); err != nil {
  2175. return nil, err
  2176. }
  2177. ret := &ListStudentsResponse{
  2178. ServerResponse: googleapi.ServerResponse{
  2179. Header: res.Header,
  2180. HTTPStatusCode: res.StatusCode,
  2181. },
  2182. }
  2183. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2184. return nil, err
  2185. }
  2186. return ret, nil
  2187. // {
  2188. // "description": "Returns a list of students of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors.",
  2189. // "httpMethod": "GET",
  2190. // "id": "classroom.courses.students.list",
  2191. // "parameterOrder": [
  2192. // "courseId"
  2193. // ],
  2194. // "parameters": {
  2195. // "courseId": {
  2196. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  2197. // "location": "path",
  2198. // "required": true,
  2199. // "type": "string"
  2200. // },
  2201. // "pageSize": {
  2202. // "description": "Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results.",
  2203. // "format": "int32",
  2204. // "location": "query",
  2205. // "type": "integer"
  2206. // },
  2207. // "pageToken": {
  2208. // "description": "nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.",
  2209. // "location": "query",
  2210. // "type": "string"
  2211. // }
  2212. // },
  2213. // "path": "v1/courses/{courseId}/students",
  2214. // "response": {
  2215. // "$ref": "ListStudentsResponse"
  2216. // },
  2217. // "scopes": [
  2218. // "https://www.googleapis.com/auth/classroom.profile.emails",
  2219. // "https://www.googleapis.com/auth/classroom.profile.photos",
  2220. // "https://www.googleapis.com/auth/classroom.rosters",
  2221. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  2222. // ]
  2223. // }
  2224. }
  2225. // Pages invokes f for each page of results.
  2226. // A non-nil error returned from f will halt the iteration.
  2227. // The provided context supersedes any context provided to the Context method.
  2228. func (c *CoursesStudentsListCall) Pages(ctx context.Context, f func(*ListStudentsResponse) error) error {
  2229. c.ctx_ = ctx
  2230. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2231. for {
  2232. x, err := c.Do()
  2233. if err != nil {
  2234. return err
  2235. }
  2236. if err := f(x); err != nil {
  2237. return err
  2238. }
  2239. if x.NextPageToken == "" {
  2240. return nil
  2241. }
  2242. c.PageToken(x.NextPageToken)
  2243. }
  2244. }
  2245. // method id "classroom.courses.teachers.create":
  2246. type CoursesTeachersCreateCall struct {
  2247. s *Service
  2248. courseId string
  2249. teacher *Teacher
  2250. urlParams_ gensupport.URLParams
  2251. ctx_ context.Context
  2252. }
  2253. // Create: Creates a teacher of a course. This method returns the
  2254. // following error codes: * `PERMISSION_DENIED` if the requesting user
  2255. // is not permitted to create teachers in this course or for access
  2256. // errors. * `NOT_FOUND` if the requested course ID does not exist. *
  2257. // `FAILED_PRECONDITION` if the requested user's account is disabled,
  2258. // for the following request errors: * CourseMemberLimitReached *
  2259. // CourseNotModifiable * CourseTeacherLimitReached *
  2260. // UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if the user is
  2261. // already a teacher or student in the course.
  2262. func (r *CoursesTeachersService) Create(courseId string, teacher *Teacher) *CoursesTeachersCreateCall {
  2263. c := &CoursesTeachersCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2264. c.courseId = courseId
  2265. c.teacher = teacher
  2266. return c
  2267. }
  2268. // Fields allows partial responses to be retrieved. See
  2269. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2270. // for more information.
  2271. func (c *CoursesTeachersCreateCall) Fields(s ...googleapi.Field) *CoursesTeachersCreateCall {
  2272. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2273. return c
  2274. }
  2275. // Context sets the context to be used in this call's Do method. Any
  2276. // pending HTTP request will be aborted if the provided context is
  2277. // canceled.
  2278. func (c *CoursesTeachersCreateCall) Context(ctx context.Context) *CoursesTeachersCreateCall {
  2279. c.ctx_ = ctx
  2280. return c
  2281. }
  2282. func (c *CoursesTeachersCreateCall) doRequest(alt string) (*http.Response, error) {
  2283. var body io.Reader = nil
  2284. body, err := googleapi.WithoutDataWrapper.JSONReader(c.teacher)
  2285. if err != nil {
  2286. return nil, err
  2287. }
  2288. ctype := "application/json"
  2289. c.urlParams_.Set("alt", alt)
  2290. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/teachers")
  2291. urls += "?" + c.urlParams_.Encode()
  2292. req, _ := http.NewRequest("POST", urls, body)
  2293. googleapi.Expand(req.URL, map[string]string{
  2294. "courseId": c.courseId,
  2295. })
  2296. req.Header.Set("Content-Type", ctype)
  2297. req.Header.Set("User-Agent", c.s.userAgent())
  2298. if c.ctx_ != nil {
  2299. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2300. }
  2301. return c.s.client.Do(req)
  2302. }
  2303. // Do executes the "classroom.courses.teachers.create" call.
  2304. // Exactly one of *Teacher or error will be non-nil. Any non-2xx status
  2305. // code is an error. Response headers are in either
  2306. // *Teacher.ServerResponse.Header or (if a response was returned at all)
  2307. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2308. // check whether the returned error was because http.StatusNotModified
  2309. // was returned.
  2310. func (c *CoursesTeachersCreateCall) Do(opts ...googleapi.CallOption) (*Teacher, error) {
  2311. gensupport.SetOptions(c.urlParams_, opts...)
  2312. res, err := c.doRequest("json")
  2313. if res != nil && res.StatusCode == http.StatusNotModified {
  2314. if res.Body != nil {
  2315. res.Body.Close()
  2316. }
  2317. return nil, &googleapi.Error{
  2318. Code: res.StatusCode,
  2319. Header: res.Header,
  2320. }
  2321. }
  2322. if err != nil {
  2323. return nil, err
  2324. }
  2325. defer googleapi.CloseBody(res)
  2326. if err := googleapi.CheckResponse(res); err != nil {
  2327. return nil, err
  2328. }
  2329. ret := &Teacher{
  2330. ServerResponse: googleapi.ServerResponse{
  2331. Header: res.Header,
  2332. HTTPStatusCode: res.StatusCode,
  2333. },
  2334. }
  2335. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2336. return nil, err
  2337. }
  2338. return ret, nil
  2339. // {
  2340. // "description": "Creates a teacher of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create teachers in this course or for access errors. * `NOT_FOUND` if the requested course ID does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled, for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * CourseTeacherLimitReached * UserGroupsMembershipLimitReached * `ALREADY_EXISTS` if the user is already a teacher or student in the course.",
  2341. // "httpMethod": "POST",
  2342. // "id": "classroom.courses.teachers.create",
  2343. // "parameterOrder": [
  2344. // "courseId"
  2345. // ],
  2346. // "parameters": {
  2347. // "courseId": {
  2348. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  2349. // "location": "path",
  2350. // "required": true,
  2351. // "type": "string"
  2352. // }
  2353. // },
  2354. // "path": "v1/courses/{courseId}/teachers",
  2355. // "request": {
  2356. // "$ref": "Teacher"
  2357. // },
  2358. // "response": {
  2359. // "$ref": "Teacher"
  2360. // },
  2361. // "scopes": [
  2362. // "https://www.googleapis.com/auth/classroom.profile.emails",
  2363. // "https://www.googleapis.com/auth/classroom.profile.photos",
  2364. // "https://www.googleapis.com/auth/classroom.rosters"
  2365. // ]
  2366. // }
  2367. }
  2368. // method id "classroom.courses.teachers.delete":
  2369. type CoursesTeachersDeleteCall struct {
  2370. s *Service
  2371. courseId string
  2372. userId string
  2373. urlParams_ gensupport.URLParams
  2374. ctx_ context.Context
  2375. }
  2376. // Delete: Deletes a teacher of a course. This method returns the
  2377. // following error codes: * `PERMISSION_DENIED` if the requesting user
  2378. // is not permitted to delete teachers of this course or for access
  2379. // errors. * `NOT_FOUND` if no teacher of this course has the requested
  2380. // ID or if the course does not exist. * `FAILED_PRECONDITION` if the
  2381. // requested ID belongs to the primary teacher of this course.
  2382. func (r *CoursesTeachersService) Delete(courseId string, userId string) *CoursesTeachersDeleteCall {
  2383. c := &CoursesTeachersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2384. c.courseId = courseId
  2385. c.userId = userId
  2386. return c
  2387. }
  2388. // Fields allows partial responses to be retrieved. See
  2389. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2390. // for more information.
  2391. func (c *CoursesTeachersDeleteCall) Fields(s ...googleapi.Field) *CoursesTeachersDeleteCall {
  2392. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2393. return c
  2394. }
  2395. // Context sets the context to be used in this call's Do method. Any
  2396. // pending HTTP request will be aborted if the provided context is
  2397. // canceled.
  2398. func (c *CoursesTeachersDeleteCall) Context(ctx context.Context) *CoursesTeachersDeleteCall {
  2399. c.ctx_ = ctx
  2400. return c
  2401. }
  2402. func (c *CoursesTeachersDeleteCall) doRequest(alt string) (*http.Response, error) {
  2403. var body io.Reader = nil
  2404. c.urlParams_.Set("alt", alt)
  2405. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/teachers/{userId}")
  2406. urls += "?" + c.urlParams_.Encode()
  2407. req, _ := http.NewRequest("DELETE", urls, body)
  2408. googleapi.Expand(req.URL, map[string]string{
  2409. "courseId": c.courseId,
  2410. "userId": c.userId,
  2411. })
  2412. req.Header.Set("User-Agent", c.s.userAgent())
  2413. if c.ctx_ != nil {
  2414. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2415. }
  2416. return c.s.client.Do(req)
  2417. }
  2418. // Do executes the "classroom.courses.teachers.delete" call.
  2419. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2420. // code is an error. Response headers are in either
  2421. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2422. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2423. // check whether the returned error was because http.StatusNotModified
  2424. // was returned.
  2425. func (c *CoursesTeachersDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2426. gensupport.SetOptions(c.urlParams_, opts...)
  2427. res, err := c.doRequest("json")
  2428. if res != nil && res.StatusCode == http.StatusNotModified {
  2429. if res.Body != nil {
  2430. res.Body.Close()
  2431. }
  2432. return nil, &googleapi.Error{
  2433. Code: res.StatusCode,
  2434. Header: res.Header,
  2435. }
  2436. }
  2437. if err != nil {
  2438. return nil, err
  2439. }
  2440. defer googleapi.CloseBody(res)
  2441. if err := googleapi.CheckResponse(res); err != nil {
  2442. return nil, err
  2443. }
  2444. ret := &Empty{
  2445. ServerResponse: googleapi.ServerResponse{
  2446. Header: res.Header,
  2447. HTTPStatusCode: res.StatusCode,
  2448. },
  2449. }
  2450. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2451. return nil, err
  2452. }
  2453. return ret, nil
  2454. // {
  2455. // "description": "Deletes a teacher of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete teachers of this course or for access errors. * `NOT_FOUND` if no teacher of this course has the requested ID or if the course does not exist. * `FAILED_PRECONDITION` if the requested ID belongs to the primary teacher of this course.",
  2456. // "httpMethod": "DELETE",
  2457. // "id": "classroom.courses.teachers.delete",
  2458. // "parameterOrder": [
  2459. // "courseId",
  2460. // "userId"
  2461. // ],
  2462. // "parameters": {
  2463. // "courseId": {
  2464. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  2465. // "location": "path",
  2466. // "required": true,
  2467. // "type": "string"
  2468. // },
  2469. // "userId": {
  2470. // "description": "Identifier of the teacher to delete. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  2471. // "location": "path",
  2472. // "required": true,
  2473. // "type": "string"
  2474. // }
  2475. // },
  2476. // "path": "v1/courses/{courseId}/teachers/{userId}",
  2477. // "response": {
  2478. // "$ref": "Empty"
  2479. // },
  2480. // "scopes": [
  2481. // "https://www.googleapis.com/auth/classroom.rosters"
  2482. // ]
  2483. // }
  2484. }
  2485. // method id "classroom.courses.teachers.get":
  2486. type CoursesTeachersGetCall struct {
  2487. s *Service
  2488. courseId string
  2489. userId string
  2490. urlParams_ gensupport.URLParams
  2491. ifNoneMatch_ string
  2492. ctx_ context.Context
  2493. }
  2494. // Get: Returns a teacher of a course. This method returns the following
  2495. // error codes: * `PERMISSION_DENIED` if the requesting user is not
  2496. // permitted to view teachers of this course or for access errors. *
  2497. // `NOT_FOUND` if no teacher of this course has the requested ID or if
  2498. // the course does not exist.
  2499. func (r *CoursesTeachersService) Get(courseId string, userId string) *CoursesTeachersGetCall {
  2500. c := &CoursesTeachersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2501. c.courseId = courseId
  2502. c.userId = userId
  2503. return c
  2504. }
  2505. // Fields allows partial responses to be retrieved. See
  2506. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2507. // for more information.
  2508. func (c *CoursesTeachersGetCall) Fields(s ...googleapi.Field) *CoursesTeachersGetCall {
  2509. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2510. return c
  2511. }
  2512. // IfNoneMatch sets the optional parameter which makes the operation
  2513. // fail if the object's ETag matches the given value. This is useful for
  2514. // getting updates only after the object has changed since the last
  2515. // request. Use googleapi.IsNotModified to check whether the response
  2516. // error from Do is the result of In-None-Match.
  2517. func (c *CoursesTeachersGetCall) IfNoneMatch(entityTag string) *CoursesTeachersGetCall {
  2518. c.ifNoneMatch_ = entityTag
  2519. return c
  2520. }
  2521. // Context sets the context to be used in this call's Do method. Any
  2522. // pending HTTP request will be aborted if the provided context is
  2523. // canceled.
  2524. func (c *CoursesTeachersGetCall) Context(ctx context.Context) *CoursesTeachersGetCall {
  2525. c.ctx_ = ctx
  2526. return c
  2527. }
  2528. func (c *CoursesTeachersGetCall) doRequest(alt string) (*http.Response, error) {
  2529. var body io.Reader = nil
  2530. c.urlParams_.Set("alt", alt)
  2531. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/teachers/{userId}")
  2532. urls += "?" + c.urlParams_.Encode()
  2533. req, _ := http.NewRequest("GET", urls, body)
  2534. googleapi.Expand(req.URL, map[string]string{
  2535. "courseId": c.courseId,
  2536. "userId": c.userId,
  2537. })
  2538. req.Header.Set("User-Agent", c.s.userAgent())
  2539. if c.ifNoneMatch_ != "" {
  2540. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2541. }
  2542. if c.ctx_ != nil {
  2543. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2544. }
  2545. return c.s.client.Do(req)
  2546. }
  2547. // Do executes the "classroom.courses.teachers.get" call.
  2548. // Exactly one of *Teacher or error will be non-nil. Any non-2xx status
  2549. // code is an error. Response headers are in either
  2550. // *Teacher.ServerResponse.Header or (if a response was returned at all)
  2551. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2552. // check whether the returned error was because http.StatusNotModified
  2553. // was returned.
  2554. func (c *CoursesTeachersGetCall) Do(opts ...googleapi.CallOption) (*Teacher, error) {
  2555. gensupport.SetOptions(c.urlParams_, opts...)
  2556. res, err := c.doRequest("json")
  2557. if res != nil && res.StatusCode == http.StatusNotModified {
  2558. if res.Body != nil {
  2559. res.Body.Close()
  2560. }
  2561. return nil, &googleapi.Error{
  2562. Code: res.StatusCode,
  2563. Header: res.Header,
  2564. }
  2565. }
  2566. if err != nil {
  2567. return nil, err
  2568. }
  2569. defer googleapi.CloseBody(res)
  2570. if err := googleapi.CheckResponse(res); err != nil {
  2571. return nil, err
  2572. }
  2573. ret := &Teacher{
  2574. ServerResponse: googleapi.ServerResponse{
  2575. Header: res.Header,
  2576. HTTPStatusCode: res.StatusCode,
  2577. },
  2578. }
  2579. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2580. return nil, err
  2581. }
  2582. return ret, nil
  2583. // {
  2584. // "description": "Returns a teacher of a course. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view teachers of this course or for access errors. * `NOT_FOUND` if no teacher of this course has the requested ID or if the course does not exist.",
  2585. // "httpMethod": "GET",
  2586. // "id": "classroom.courses.teachers.get",
  2587. // "parameterOrder": [
  2588. // "courseId",
  2589. // "userId"
  2590. // ],
  2591. // "parameters": {
  2592. // "courseId": {
  2593. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  2594. // "location": "path",
  2595. // "required": true,
  2596. // "type": "string"
  2597. // },
  2598. // "userId": {
  2599. // "description": "Identifier of the teacher to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  2600. // "location": "path",
  2601. // "required": true,
  2602. // "type": "string"
  2603. // }
  2604. // },
  2605. // "path": "v1/courses/{courseId}/teachers/{userId}",
  2606. // "response": {
  2607. // "$ref": "Teacher"
  2608. // },
  2609. // "scopes": [
  2610. // "https://www.googleapis.com/auth/classroom.profile.emails",
  2611. // "https://www.googleapis.com/auth/classroom.profile.photos",
  2612. // "https://www.googleapis.com/auth/classroom.rosters",
  2613. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  2614. // ]
  2615. // }
  2616. }
  2617. // method id "classroom.courses.teachers.list":
  2618. type CoursesTeachersListCall struct {
  2619. s *Service
  2620. courseId string
  2621. urlParams_ gensupport.URLParams
  2622. ifNoneMatch_ string
  2623. ctx_ context.Context
  2624. }
  2625. // List: Returns a list of teachers of this course that the requester is
  2626. // permitted to view. This method returns the following error codes: *
  2627. // `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for
  2628. // access errors.
  2629. func (r *CoursesTeachersService) List(courseId string) *CoursesTeachersListCall {
  2630. c := &CoursesTeachersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2631. c.courseId = courseId
  2632. return c
  2633. }
  2634. // PageSize sets the optional parameter "pageSize": Maximum number of
  2635. // items to return. Zero means no maximum. The server may return fewer
  2636. // than the specified number of results.
  2637. func (c *CoursesTeachersListCall) PageSize(pageSize int64) *CoursesTeachersListCall {
  2638. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  2639. return c
  2640. }
  2641. // PageToken sets the optional parameter "pageToken": nextPageToken
  2642. // value returned from a previous list call, indicating that the
  2643. // subsequent page of results should be returned. The list request must
  2644. // be otherwise identical to the one that resulted in this token.
  2645. func (c *CoursesTeachersListCall) PageToken(pageToken string) *CoursesTeachersListCall {
  2646. c.urlParams_.Set("pageToken", pageToken)
  2647. return c
  2648. }
  2649. // Fields allows partial responses to be retrieved. See
  2650. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2651. // for more information.
  2652. func (c *CoursesTeachersListCall) Fields(s ...googleapi.Field) *CoursesTeachersListCall {
  2653. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2654. return c
  2655. }
  2656. // IfNoneMatch sets the optional parameter which makes the operation
  2657. // fail if the object's ETag matches the given value. This is useful for
  2658. // getting updates only after the object has changed since the last
  2659. // request. Use googleapi.IsNotModified to check whether the response
  2660. // error from Do is the result of In-None-Match.
  2661. func (c *CoursesTeachersListCall) IfNoneMatch(entityTag string) *CoursesTeachersListCall {
  2662. c.ifNoneMatch_ = entityTag
  2663. return c
  2664. }
  2665. // Context sets the context to be used in this call's Do method. Any
  2666. // pending HTTP request will be aborted if the provided context is
  2667. // canceled.
  2668. func (c *CoursesTeachersListCall) Context(ctx context.Context) *CoursesTeachersListCall {
  2669. c.ctx_ = ctx
  2670. return c
  2671. }
  2672. func (c *CoursesTeachersListCall) doRequest(alt string) (*http.Response, error) {
  2673. var body io.Reader = nil
  2674. c.urlParams_.Set("alt", alt)
  2675. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/courses/{courseId}/teachers")
  2676. urls += "?" + c.urlParams_.Encode()
  2677. req, _ := http.NewRequest("GET", urls, body)
  2678. googleapi.Expand(req.URL, map[string]string{
  2679. "courseId": c.courseId,
  2680. })
  2681. req.Header.Set("User-Agent", c.s.userAgent())
  2682. if c.ifNoneMatch_ != "" {
  2683. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2684. }
  2685. if c.ctx_ != nil {
  2686. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2687. }
  2688. return c.s.client.Do(req)
  2689. }
  2690. // Do executes the "classroom.courses.teachers.list" call.
  2691. // Exactly one of *ListTeachersResponse or error will be non-nil. Any
  2692. // non-2xx status code is an error. Response headers are in either
  2693. // *ListTeachersResponse.ServerResponse.Header or (if a response was
  2694. // returned at all) in error.(*googleapi.Error).Header. Use
  2695. // googleapi.IsNotModified to check whether the returned error was
  2696. // because http.StatusNotModified was returned.
  2697. func (c *CoursesTeachersListCall) Do(opts ...googleapi.CallOption) (*ListTeachersResponse, error) {
  2698. gensupport.SetOptions(c.urlParams_, opts...)
  2699. res, err := c.doRequest("json")
  2700. if res != nil && res.StatusCode == http.StatusNotModified {
  2701. if res.Body != nil {
  2702. res.Body.Close()
  2703. }
  2704. return nil, &googleapi.Error{
  2705. Code: res.StatusCode,
  2706. Header: res.Header,
  2707. }
  2708. }
  2709. if err != nil {
  2710. return nil, err
  2711. }
  2712. defer googleapi.CloseBody(res)
  2713. if err := googleapi.CheckResponse(res); err != nil {
  2714. return nil, err
  2715. }
  2716. ret := &ListTeachersResponse{
  2717. ServerResponse: googleapi.ServerResponse{
  2718. Header: res.Header,
  2719. HTTPStatusCode: res.StatusCode,
  2720. },
  2721. }
  2722. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2723. return nil, err
  2724. }
  2725. return ret, nil
  2726. // {
  2727. // "description": "Returns a list of teachers of this course that the requester is permitted to view. This method returns the following error codes: * `NOT_FOUND` if the course does not exist. * `PERMISSION_DENIED` for access errors.",
  2728. // "httpMethod": "GET",
  2729. // "id": "classroom.courses.teachers.list",
  2730. // "parameterOrder": [
  2731. // "courseId"
  2732. // ],
  2733. // "parameters": {
  2734. // "courseId": {
  2735. // "description": "Identifier of the course. This identifier can be either the Classroom-assigned identifier or an alias.",
  2736. // "location": "path",
  2737. // "required": true,
  2738. // "type": "string"
  2739. // },
  2740. // "pageSize": {
  2741. // "description": "Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results.",
  2742. // "format": "int32",
  2743. // "location": "query",
  2744. // "type": "integer"
  2745. // },
  2746. // "pageToken": {
  2747. // "description": "nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.",
  2748. // "location": "query",
  2749. // "type": "string"
  2750. // }
  2751. // },
  2752. // "path": "v1/courses/{courseId}/teachers",
  2753. // "response": {
  2754. // "$ref": "ListTeachersResponse"
  2755. // },
  2756. // "scopes": [
  2757. // "https://www.googleapis.com/auth/classroom.profile.emails",
  2758. // "https://www.googleapis.com/auth/classroom.profile.photos",
  2759. // "https://www.googleapis.com/auth/classroom.rosters",
  2760. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  2761. // ]
  2762. // }
  2763. }
  2764. // Pages invokes f for each page of results.
  2765. // A non-nil error returned from f will halt the iteration.
  2766. // The provided context supersedes any context provided to the Context method.
  2767. func (c *CoursesTeachersListCall) Pages(ctx context.Context, f func(*ListTeachersResponse) error) error {
  2768. c.ctx_ = ctx
  2769. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2770. for {
  2771. x, err := c.Do()
  2772. if err != nil {
  2773. return err
  2774. }
  2775. if err := f(x); err != nil {
  2776. return err
  2777. }
  2778. if x.NextPageToken == "" {
  2779. return nil
  2780. }
  2781. c.PageToken(x.NextPageToken)
  2782. }
  2783. }
  2784. // method id "classroom.invitations.accept":
  2785. type InvitationsAcceptCall struct {
  2786. s *Service
  2787. id string
  2788. urlParams_ gensupport.URLParams
  2789. ctx_ context.Context
  2790. }
  2791. // Accept: Accepts an invitation, removing it and adding the invited
  2792. // user to the teachers or students (as appropriate) of the specified
  2793. // course. Only the invited user may accept an invitation. This method
  2794. // returns the following error codes: * `PERMISSION_DENIED` if the
  2795. // requesting user is not permitted to accept the requested invitation
  2796. // or for access errors. * `FAILED_PRECONDITION` for the following
  2797. // request errors: * CourseMemberLimitReached * CourseNotModifiable *
  2798. // CourseTeacherLimitReached * UserGroupsMembershipLimitReached *
  2799. // `NOT_FOUND` if no invitation exists with the requested ID.
  2800. func (r *InvitationsService) Accept(id string) *InvitationsAcceptCall {
  2801. c := &InvitationsAcceptCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2802. c.id = id
  2803. return c
  2804. }
  2805. // Fields allows partial responses to be retrieved. See
  2806. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2807. // for more information.
  2808. func (c *InvitationsAcceptCall) Fields(s ...googleapi.Field) *InvitationsAcceptCall {
  2809. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2810. return c
  2811. }
  2812. // Context sets the context to be used in this call's Do method. Any
  2813. // pending HTTP request will be aborted if the provided context is
  2814. // canceled.
  2815. func (c *InvitationsAcceptCall) Context(ctx context.Context) *InvitationsAcceptCall {
  2816. c.ctx_ = ctx
  2817. return c
  2818. }
  2819. func (c *InvitationsAcceptCall) doRequest(alt string) (*http.Response, error) {
  2820. var body io.Reader = nil
  2821. c.urlParams_.Set("alt", alt)
  2822. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/invitations/{id}:accept")
  2823. urls += "?" + c.urlParams_.Encode()
  2824. req, _ := http.NewRequest("POST", urls, body)
  2825. googleapi.Expand(req.URL, map[string]string{
  2826. "id": c.id,
  2827. })
  2828. req.Header.Set("User-Agent", c.s.userAgent())
  2829. if c.ctx_ != nil {
  2830. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2831. }
  2832. return c.s.client.Do(req)
  2833. }
  2834. // Do executes the "classroom.invitations.accept" call.
  2835. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2836. // code is an error. Response headers are in either
  2837. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2838. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2839. // check whether the returned error was because http.StatusNotModified
  2840. // was returned.
  2841. func (c *InvitationsAcceptCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2842. gensupport.SetOptions(c.urlParams_, opts...)
  2843. res, err := c.doRequest("json")
  2844. if res != nil && res.StatusCode == http.StatusNotModified {
  2845. if res.Body != nil {
  2846. res.Body.Close()
  2847. }
  2848. return nil, &googleapi.Error{
  2849. Code: res.StatusCode,
  2850. Header: res.Header,
  2851. }
  2852. }
  2853. if err != nil {
  2854. return nil, err
  2855. }
  2856. defer googleapi.CloseBody(res)
  2857. if err := googleapi.CheckResponse(res); err != nil {
  2858. return nil, err
  2859. }
  2860. ret := &Empty{
  2861. ServerResponse: googleapi.ServerResponse{
  2862. Header: res.Header,
  2863. HTTPStatusCode: res.StatusCode,
  2864. },
  2865. }
  2866. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2867. return nil, err
  2868. }
  2869. return ret, nil
  2870. // {
  2871. // "description": "Accepts an invitation, removing it and adding the invited user to the teachers or students (as appropriate) of the specified course. Only the invited user may accept an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to accept the requested invitation or for access errors. * `FAILED_PRECONDITION` for the following request errors: * CourseMemberLimitReached * CourseNotModifiable * CourseTeacherLimitReached * UserGroupsMembershipLimitReached * `NOT_FOUND` if no invitation exists with the requested ID.",
  2872. // "httpMethod": "POST",
  2873. // "id": "classroom.invitations.accept",
  2874. // "parameterOrder": [
  2875. // "id"
  2876. // ],
  2877. // "parameters": {
  2878. // "id": {
  2879. // "description": "Identifier of the invitation to accept.",
  2880. // "location": "path",
  2881. // "required": true,
  2882. // "type": "string"
  2883. // }
  2884. // },
  2885. // "path": "v1/invitations/{id}:accept",
  2886. // "response": {
  2887. // "$ref": "Empty"
  2888. // },
  2889. // "scopes": [
  2890. // "https://www.googleapis.com/auth/classroom.rosters"
  2891. // ]
  2892. // }
  2893. }
  2894. // method id "classroom.invitations.create":
  2895. type InvitationsCreateCall struct {
  2896. s *Service
  2897. invitation *Invitation
  2898. urlParams_ gensupport.URLParams
  2899. ctx_ context.Context
  2900. }
  2901. // Create: Creates an invitation. Only one invitation for a user and
  2902. // course may exist at a time. Delete and re-create an invitation to
  2903. // make changes. This method returns the following error codes: *
  2904. // `PERMISSION_DENIED` if the requesting user is not permitted to create
  2905. // invitations for this course or for access errors. * `NOT_FOUND` if
  2906. // the course or the user does not exist. * `FAILED_PRECONDITION` if the
  2907. // requested user's account is disabled or if the user already has this
  2908. // role or a role with greater permissions. * `ALREADY_EXISTS` if an
  2909. // invitation for the specified user and course already exists.
  2910. func (r *InvitationsService) Create(invitation *Invitation) *InvitationsCreateCall {
  2911. c := &InvitationsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2912. c.invitation = invitation
  2913. return c
  2914. }
  2915. // Fields allows partial responses to be retrieved. See
  2916. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2917. // for more information.
  2918. func (c *InvitationsCreateCall) Fields(s ...googleapi.Field) *InvitationsCreateCall {
  2919. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2920. return c
  2921. }
  2922. // Context sets the context to be used in this call's Do method. Any
  2923. // pending HTTP request will be aborted if the provided context is
  2924. // canceled.
  2925. func (c *InvitationsCreateCall) Context(ctx context.Context) *InvitationsCreateCall {
  2926. c.ctx_ = ctx
  2927. return c
  2928. }
  2929. func (c *InvitationsCreateCall) doRequest(alt string) (*http.Response, error) {
  2930. var body io.Reader = nil
  2931. body, err := googleapi.WithoutDataWrapper.JSONReader(c.invitation)
  2932. if err != nil {
  2933. return nil, err
  2934. }
  2935. ctype := "application/json"
  2936. c.urlParams_.Set("alt", alt)
  2937. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/invitations")
  2938. urls += "?" + c.urlParams_.Encode()
  2939. req, _ := http.NewRequest("POST", urls, body)
  2940. googleapi.SetOpaque(req.URL)
  2941. req.Header.Set("Content-Type", ctype)
  2942. req.Header.Set("User-Agent", c.s.userAgent())
  2943. if c.ctx_ != nil {
  2944. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2945. }
  2946. return c.s.client.Do(req)
  2947. }
  2948. // Do executes the "classroom.invitations.create" call.
  2949. // Exactly one of *Invitation or error will be non-nil. Any non-2xx
  2950. // status code is an error. Response headers are in either
  2951. // *Invitation.ServerResponse.Header or (if a response was returned at
  2952. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2953. // to check whether the returned error was because
  2954. // http.StatusNotModified was returned.
  2955. func (c *InvitationsCreateCall) Do(opts ...googleapi.CallOption) (*Invitation, error) {
  2956. gensupport.SetOptions(c.urlParams_, opts...)
  2957. res, err := c.doRequest("json")
  2958. if res != nil && res.StatusCode == http.StatusNotModified {
  2959. if res.Body != nil {
  2960. res.Body.Close()
  2961. }
  2962. return nil, &googleapi.Error{
  2963. Code: res.StatusCode,
  2964. Header: res.Header,
  2965. }
  2966. }
  2967. if err != nil {
  2968. return nil, err
  2969. }
  2970. defer googleapi.CloseBody(res)
  2971. if err := googleapi.CheckResponse(res); err != nil {
  2972. return nil, err
  2973. }
  2974. ret := &Invitation{
  2975. ServerResponse: googleapi.ServerResponse{
  2976. Header: res.Header,
  2977. HTTPStatusCode: res.StatusCode,
  2978. },
  2979. }
  2980. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2981. return nil, err
  2982. }
  2983. return ret, nil
  2984. // {
  2985. // "description": "Creates an invitation. Only one invitation for a user and course may exist at a time. Delete and re-create an invitation to make changes. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to create invitations for this course or for access errors. * `NOT_FOUND` if the course or the user does not exist. * `FAILED_PRECONDITION` if the requested user's account is disabled or if the user already has this role or a role with greater permissions. * `ALREADY_EXISTS` if an invitation for the specified user and course already exists.",
  2986. // "httpMethod": "POST",
  2987. // "id": "classroom.invitations.create",
  2988. // "path": "v1/invitations",
  2989. // "request": {
  2990. // "$ref": "Invitation"
  2991. // },
  2992. // "response": {
  2993. // "$ref": "Invitation"
  2994. // },
  2995. // "scopes": [
  2996. // "https://www.googleapis.com/auth/classroom.rosters"
  2997. // ]
  2998. // }
  2999. }
  3000. // method id "classroom.invitations.delete":
  3001. type InvitationsDeleteCall struct {
  3002. s *Service
  3003. id string
  3004. urlParams_ gensupport.URLParams
  3005. ctx_ context.Context
  3006. }
  3007. // Delete: Deletes an invitation. This method returns the following
  3008. // error codes: * `PERMISSION_DENIED` if the requesting user is not
  3009. // permitted to delete the requested invitation or for access errors. *
  3010. // `NOT_FOUND` if no invitation exists with the requested ID.
  3011. func (r *InvitationsService) Delete(id string) *InvitationsDeleteCall {
  3012. c := &InvitationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3013. c.id = id
  3014. return c
  3015. }
  3016. // Fields allows partial responses to be retrieved. See
  3017. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3018. // for more information.
  3019. func (c *InvitationsDeleteCall) Fields(s ...googleapi.Field) *InvitationsDeleteCall {
  3020. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3021. return c
  3022. }
  3023. // Context sets the context to be used in this call's Do method. Any
  3024. // pending HTTP request will be aborted if the provided context is
  3025. // canceled.
  3026. func (c *InvitationsDeleteCall) Context(ctx context.Context) *InvitationsDeleteCall {
  3027. c.ctx_ = ctx
  3028. return c
  3029. }
  3030. func (c *InvitationsDeleteCall) doRequest(alt string) (*http.Response, error) {
  3031. var body io.Reader = nil
  3032. c.urlParams_.Set("alt", alt)
  3033. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/invitations/{id}")
  3034. urls += "?" + c.urlParams_.Encode()
  3035. req, _ := http.NewRequest("DELETE", urls, body)
  3036. googleapi.Expand(req.URL, map[string]string{
  3037. "id": c.id,
  3038. })
  3039. req.Header.Set("User-Agent", c.s.userAgent())
  3040. if c.ctx_ != nil {
  3041. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3042. }
  3043. return c.s.client.Do(req)
  3044. }
  3045. // Do executes the "classroom.invitations.delete" call.
  3046. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  3047. // code is an error. Response headers are in either
  3048. // *Empty.ServerResponse.Header or (if a response was returned at all)
  3049. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3050. // check whether the returned error was because http.StatusNotModified
  3051. // was returned.
  3052. func (c *InvitationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  3053. gensupport.SetOptions(c.urlParams_, opts...)
  3054. res, err := c.doRequest("json")
  3055. if res != nil && res.StatusCode == http.StatusNotModified {
  3056. if res.Body != nil {
  3057. res.Body.Close()
  3058. }
  3059. return nil, &googleapi.Error{
  3060. Code: res.StatusCode,
  3061. Header: res.Header,
  3062. }
  3063. }
  3064. if err != nil {
  3065. return nil, err
  3066. }
  3067. defer googleapi.CloseBody(res)
  3068. if err := googleapi.CheckResponse(res); err != nil {
  3069. return nil, err
  3070. }
  3071. ret := &Empty{
  3072. ServerResponse: googleapi.ServerResponse{
  3073. Header: res.Header,
  3074. HTTPStatusCode: res.StatusCode,
  3075. },
  3076. }
  3077. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3078. return nil, err
  3079. }
  3080. return ret, nil
  3081. // {
  3082. // "description": "Deletes an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to delete the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID.",
  3083. // "httpMethod": "DELETE",
  3084. // "id": "classroom.invitations.delete",
  3085. // "parameterOrder": [
  3086. // "id"
  3087. // ],
  3088. // "parameters": {
  3089. // "id": {
  3090. // "description": "Identifier of the invitation to delete.",
  3091. // "location": "path",
  3092. // "required": true,
  3093. // "type": "string"
  3094. // }
  3095. // },
  3096. // "path": "v1/invitations/{id}",
  3097. // "response": {
  3098. // "$ref": "Empty"
  3099. // },
  3100. // "scopes": [
  3101. // "https://www.googleapis.com/auth/classroom.rosters"
  3102. // ]
  3103. // }
  3104. }
  3105. // method id "classroom.invitations.get":
  3106. type InvitationsGetCall struct {
  3107. s *Service
  3108. id string
  3109. urlParams_ gensupport.URLParams
  3110. ifNoneMatch_ string
  3111. ctx_ context.Context
  3112. }
  3113. // Get: Returns an invitation. This method returns the following error
  3114. // codes: * `PERMISSION_DENIED` if the requesting user is not permitted
  3115. // to view the requested invitation or for access errors. * `NOT_FOUND`
  3116. // if no invitation exists with the requested ID.
  3117. func (r *InvitationsService) Get(id string) *InvitationsGetCall {
  3118. c := &InvitationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3119. c.id = id
  3120. return c
  3121. }
  3122. // Fields allows partial responses to be retrieved. See
  3123. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3124. // for more information.
  3125. func (c *InvitationsGetCall) Fields(s ...googleapi.Field) *InvitationsGetCall {
  3126. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3127. return c
  3128. }
  3129. // IfNoneMatch sets the optional parameter which makes the operation
  3130. // fail if the object's ETag matches the given value. This is useful for
  3131. // getting updates only after the object has changed since the last
  3132. // request. Use googleapi.IsNotModified to check whether the response
  3133. // error from Do is the result of In-None-Match.
  3134. func (c *InvitationsGetCall) IfNoneMatch(entityTag string) *InvitationsGetCall {
  3135. c.ifNoneMatch_ = entityTag
  3136. return c
  3137. }
  3138. // Context sets the context to be used in this call's Do method. Any
  3139. // pending HTTP request will be aborted if the provided context is
  3140. // canceled.
  3141. func (c *InvitationsGetCall) Context(ctx context.Context) *InvitationsGetCall {
  3142. c.ctx_ = ctx
  3143. return c
  3144. }
  3145. func (c *InvitationsGetCall) doRequest(alt string) (*http.Response, error) {
  3146. var body io.Reader = nil
  3147. c.urlParams_.Set("alt", alt)
  3148. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/invitations/{id}")
  3149. urls += "?" + c.urlParams_.Encode()
  3150. req, _ := http.NewRequest("GET", urls, body)
  3151. googleapi.Expand(req.URL, map[string]string{
  3152. "id": c.id,
  3153. })
  3154. req.Header.Set("User-Agent", c.s.userAgent())
  3155. if c.ifNoneMatch_ != "" {
  3156. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  3157. }
  3158. if c.ctx_ != nil {
  3159. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3160. }
  3161. return c.s.client.Do(req)
  3162. }
  3163. // Do executes the "classroom.invitations.get" call.
  3164. // Exactly one of *Invitation or error will be non-nil. Any non-2xx
  3165. // status code is an error. Response headers are in either
  3166. // *Invitation.ServerResponse.Header or (if a response was returned at
  3167. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3168. // to check whether the returned error was because
  3169. // http.StatusNotModified was returned.
  3170. func (c *InvitationsGetCall) Do(opts ...googleapi.CallOption) (*Invitation, error) {
  3171. gensupport.SetOptions(c.urlParams_, opts...)
  3172. res, err := c.doRequest("json")
  3173. if res != nil && res.StatusCode == http.StatusNotModified {
  3174. if res.Body != nil {
  3175. res.Body.Close()
  3176. }
  3177. return nil, &googleapi.Error{
  3178. Code: res.StatusCode,
  3179. Header: res.Header,
  3180. }
  3181. }
  3182. if err != nil {
  3183. return nil, err
  3184. }
  3185. defer googleapi.CloseBody(res)
  3186. if err := googleapi.CheckResponse(res); err != nil {
  3187. return nil, err
  3188. }
  3189. ret := &Invitation{
  3190. ServerResponse: googleapi.ServerResponse{
  3191. Header: res.Header,
  3192. HTTPStatusCode: res.StatusCode,
  3193. },
  3194. }
  3195. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3196. return nil, err
  3197. }
  3198. return ret, nil
  3199. // {
  3200. // "description": "Returns an invitation. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to view the requested invitation or for access errors. * `NOT_FOUND` if no invitation exists with the requested ID.",
  3201. // "httpMethod": "GET",
  3202. // "id": "classroom.invitations.get",
  3203. // "parameterOrder": [
  3204. // "id"
  3205. // ],
  3206. // "parameters": {
  3207. // "id": {
  3208. // "description": "Identifier of the invitation to return.",
  3209. // "location": "path",
  3210. // "required": true,
  3211. // "type": "string"
  3212. // }
  3213. // },
  3214. // "path": "v1/invitations/{id}",
  3215. // "response": {
  3216. // "$ref": "Invitation"
  3217. // },
  3218. // "scopes": [
  3219. // "https://www.googleapis.com/auth/classroom.rosters",
  3220. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  3221. // ]
  3222. // }
  3223. }
  3224. // method id "classroom.invitations.list":
  3225. type InvitationsListCall struct {
  3226. s *Service
  3227. urlParams_ gensupport.URLParams
  3228. ifNoneMatch_ string
  3229. ctx_ context.Context
  3230. }
  3231. // List: Returns a list of invitations that the requesting user is
  3232. // permitted to view, restricted to those that match the list request.
  3233. // *Note:* At least one of `user_id` or `course_id` must be supplied.
  3234. // Both fields can be supplied. This method returns the following error
  3235. // codes: * `PERMISSION_DENIED` for access errors.
  3236. func (r *InvitationsService) List() *InvitationsListCall {
  3237. c := &InvitationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3238. return c
  3239. }
  3240. // CourseId sets the optional parameter "courseId": Restricts returned
  3241. // invitations to those for a course with the specified identifier.
  3242. func (c *InvitationsListCall) CourseId(courseId string) *InvitationsListCall {
  3243. c.urlParams_.Set("courseId", courseId)
  3244. return c
  3245. }
  3246. // PageSize sets the optional parameter "pageSize": Maximum number of
  3247. // items to return. Zero means no maximum. The server may return fewer
  3248. // than the specified number of results.
  3249. func (c *InvitationsListCall) PageSize(pageSize int64) *InvitationsListCall {
  3250. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  3251. return c
  3252. }
  3253. // PageToken sets the optional parameter "pageToken": nextPageToken
  3254. // value returned from a previous list call, indicating that the
  3255. // subsequent page of results should be returned. The list request must
  3256. // be otherwise identical to the one that resulted in this token.
  3257. func (c *InvitationsListCall) PageToken(pageToken string) *InvitationsListCall {
  3258. c.urlParams_.Set("pageToken", pageToken)
  3259. return c
  3260. }
  3261. // UserId sets the optional parameter "userId": Restricts returned
  3262. // invitations to those for a specific user. The identifier can be one
  3263. // of the following: * the numeric identifier for the user * the email
  3264. // address of the user * the string literal "me", indicating the
  3265. // requesting user
  3266. func (c *InvitationsListCall) UserId(userId string) *InvitationsListCall {
  3267. c.urlParams_.Set("userId", userId)
  3268. return c
  3269. }
  3270. // Fields allows partial responses to be retrieved. See
  3271. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3272. // for more information.
  3273. func (c *InvitationsListCall) Fields(s ...googleapi.Field) *InvitationsListCall {
  3274. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3275. return c
  3276. }
  3277. // IfNoneMatch sets the optional parameter which makes the operation
  3278. // fail if the object's ETag matches the given value. This is useful for
  3279. // getting updates only after the object has changed since the last
  3280. // request. Use googleapi.IsNotModified to check whether the response
  3281. // error from Do is the result of In-None-Match.
  3282. func (c *InvitationsListCall) IfNoneMatch(entityTag string) *InvitationsListCall {
  3283. c.ifNoneMatch_ = entityTag
  3284. return c
  3285. }
  3286. // Context sets the context to be used in this call's Do method. Any
  3287. // pending HTTP request will be aborted if the provided context is
  3288. // canceled.
  3289. func (c *InvitationsListCall) Context(ctx context.Context) *InvitationsListCall {
  3290. c.ctx_ = ctx
  3291. return c
  3292. }
  3293. func (c *InvitationsListCall) doRequest(alt string) (*http.Response, error) {
  3294. var body io.Reader = nil
  3295. c.urlParams_.Set("alt", alt)
  3296. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/invitations")
  3297. urls += "?" + c.urlParams_.Encode()
  3298. req, _ := http.NewRequest("GET", urls, body)
  3299. googleapi.SetOpaque(req.URL)
  3300. req.Header.Set("User-Agent", c.s.userAgent())
  3301. if c.ifNoneMatch_ != "" {
  3302. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  3303. }
  3304. if c.ctx_ != nil {
  3305. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3306. }
  3307. return c.s.client.Do(req)
  3308. }
  3309. // Do executes the "classroom.invitations.list" call.
  3310. // Exactly one of *ListInvitationsResponse or error will be non-nil. Any
  3311. // non-2xx status code is an error. Response headers are in either
  3312. // *ListInvitationsResponse.ServerResponse.Header or (if a response was
  3313. // returned at all) in error.(*googleapi.Error).Header. Use
  3314. // googleapi.IsNotModified to check whether the returned error was
  3315. // because http.StatusNotModified was returned.
  3316. func (c *InvitationsListCall) Do(opts ...googleapi.CallOption) (*ListInvitationsResponse, error) {
  3317. gensupport.SetOptions(c.urlParams_, opts...)
  3318. res, err := c.doRequest("json")
  3319. if res != nil && res.StatusCode == http.StatusNotModified {
  3320. if res.Body != nil {
  3321. res.Body.Close()
  3322. }
  3323. return nil, &googleapi.Error{
  3324. Code: res.StatusCode,
  3325. Header: res.Header,
  3326. }
  3327. }
  3328. if err != nil {
  3329. return nil, err
  3330. }
  3331. defer googleapi.CloseBody(res)
  3332. if err := googleapi.CheckResponse(res); err != nil {
  3333. return nil, err
  3334. }
  3335. ret := &ListInvitationsResponse{
  3336. ServerResponse: googleapi.ServerResponse{
  3337. Header: res.Header,
  3338. HTTPStatusCode: res.StatusCode,
  3339. },
  3340. }
  3341. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3342. return nil, err
  3343. }
  3344. return ret, nil
  3345. // {
  3346. // "description": "Returns a list of invitations that the requesting user is permitted to view, restricted to those that match the list request. *Note:* At least one of `user_id` or `course_id` must be supplied. Both fields can be supplied. This method returns the following error codes: * `PERMISSION_DENIED` for access errors.",
  3347. // "httpMethod": "GET",
  3348. // "id": "classroom.invitations.list",
  3349. // "parameters": {
  3350. // "courseId": {
  3351. // "description": "Restricts returned invitations to those for a course with the specified identifier.",
  3352. // "location": "query",
  3353. // "type": "string"
  3354. // },
  3355. // "pageSize": {
  3356. // "description": "Maximum number of items to return. Zero means no maximum. The server may return fewer than the specified number of results.",
  3357. // "format": "int32",
  3358. // "location": "query",
  3359. // "type": "integer"
  3360. // },
  3361. // "pageToken": {
  3362. // "description": "nextPageToken value returned from a previous list call, indicating that the subsequent page of results should be returned. The list request must be otherwise identical to the one that resulted in this token.",
  3363. // "location": "query",
  3364. // "type": "string"
  3365. // },
  3366. // "userId": {
  3367. // "description": "Restricts returned invitations to those for a specific user. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  3368. // "location": "query",
  3369. // "type": "string"
  3370. // }
  3371. // },
  3372. // "path": "v1/invitations",
  3373. // "response": {
  3374. // "$ref": "ListInvitationsResponse"
  3375. // },
  3376. // "scopes": [
  3377. // "https://www.googleapis.com/auth/classroom.rosters",
  3378. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  3379. // ]
  3380. // }
  3381. }
  3382. // Pages invokes f for each page of results.
  3383. // A non-nil error returned from f will halt the iteration.
  3384. // The provided context supersedes any context provided to the Context method.
  3385. func (c *InvitationsListCall) Pages(ctx context.Context, f func(*ListInvitationsResponse) error) error {
  3386. c.ctx_ = ctx
  3387. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3388. for {
  3389. x, err := c.Do()
  3390. if err != nil {
  3391. return err
  3392. }
  3393. if err := f(x); err != nil {
  3394. return err
  3395. }
  3396. if x.NextPageToken == "" {
  3397. return nil
  3398. }
  3399. c.PageToken(x.NextPageToken)
  3400. }
  3401. }
  3402. // method id "classroom.userProfiles.get":
  3403. type UserProfilesGetCall struct {
  3404. s *Service
  3405. userId string
  3406. urlParams_ gensupport.URLParams
  3407. ifNoneMatch_ string
  3408. ctx_ context.Context
  3409. }
  3410. // Get: Returns a user profile. This method returns the following error
  3411. // codes: * `PERMISSION_DENIED` if the requesting user is not permitted
  3412. // to access this user profile or if no profile exists with the
  3413. // requested ID or for access errors.
  3414. func (r *UserProfilesService) Get(userId string) *UserProfilesGetCall {
  3415. c := &UserProfilesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3416. c.userId = userId
  3417. return c
  3418. }
  3419. // Fields allows partial responses to be retrieved. See
  3420. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3421. // for more information.
  3422. func (c *UserProfilesGetCall) Fields(s ...googleapi.Field) *UserProfilesGetCall {
  3423. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3424. return c
  3425. }
  3426. // IfNoneMatch sets the optional parameter which makes the operation
  3427. // fail if the object's ETag matches the given value. This is useful for
  3428. // getting updates only after the object has changed since the last
  3429. // request. Use googleapi.IsNotModified to check whether the response
  3430. // error from Do is the result of In-None-Match.
  3431. func (c *UserProfilesGetCall) IfNoneMatch(entityTag string) *UserProfilesGetCall {
  3432. c.ifNoneMatch_ = entityTag
  3433. return c
  3434. }
  3435. // Context sets the context to be used in this call's Do method. Any
  3436. // pending HTTP request will be aborted if the provided context is
  3437. // canceled.
  3438. func (c *UserProfilesGetCall) Context(ctx context.Context) *UserProfilesGetCall {
  3439. c.ctx_ = ctx
  3440. return c
  3441. }
  3442. func (c *UserProfilesGetCall) doRequest(alt string) (*http.Response, error) {
  3443. var body io.Reader = nil
  3444. c.urlParams_.Set("alt", alt)
  3445. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/userProfiles/{userId}")
  3446. urls += "?" + c.urlParams_.Encode()
  3447. req, _ := http.NewRequest("GET", urls, body)
  3448. googleapi.Expand(req.URL, map[string]string{
  3449. "userId": c.userId,
  3450. })
  3451. req.Header.Set("User-Agent", c.s.userAgent())
  3452. if c.ifNoneMatch_ != "" {
  3453. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  3454. }
  3455. if c.ctx_ != nil {
  3456. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3457. }
  3458. return c.s.client.Do(req)
  3459. }
  3460. // Do executes the "classroom.userProfiles.get" call.
  3461. // Exactly one of *UserProfile or error will be non-nil. Any non-2xx
  3462. // status code is an error. Response headers are in either
  3463. // *UserProfile.ServerResponse.Header or (if a response was returned at
  3464. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3465. // to check whether the returned error was because
  3466. // http.StatusNotModified was returned.
  3467. func (c *UserProfilesGetCall) Do(opts ...googleapi.CallOption) (*UserProfile, error) {
  3468. gensupport.SetOptions(c.urlParams_, opts...)
  3469. res, err := c.doRequest("json")
  3470. if res != nil && res.StatusCode == http.StatusNotModified {
  3471. if res.Body != nil {
  3472. res.Body.Close()
  3473. }
  3474. return nil, &googleapi.Error{
  3475. Code: res.StatusCode,
  3476. Header: res.Header,
  3477. }
  3478. }
  3479. if err != nil {
  3480. return nil, err
  3481. }
  3482. defer googleapi.CloseBody(res)
  3483. if err := googleapi.CheckResponse(res); err != nil {
  3484. return nil, err
  3485. }
  3486. ret := &UserProfile{
  3487. ServerResponse: googleapi.ServerResponse{
  3488. Header: res.Header,
  3489. HTTPStatusCode: res.StatusCode,
  3490. },
  3491. }
  3492. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3493. return nil, err
  3494. }
  3495. return ret, nil
  3496. // {
  3497. // "description": "Returns a user profile. This method returns the following error codes: * `PERMISSION_DENIED` if the requesting user is not permitted to access this user profile or if no profile exists with the requested ID or for access errors.",
  3498. // "httpMethod": "GET",
  3499. // "id": "classroom.userProfiles.get",
  3500. // "parameterOrder": [
  3501. // "userId"
  3502. // ],
  3503. // "parameters": {
  3504. // "userId": {
  3505. // "description": "Identifier of the profile to return. The identifier can be one of the following: * the numeric identifier for the user * the email address of the user * the string literal `\"me\"`, indicating the requesting user",
  3506. // "location": "path",
  3507. // "required": true,
  3508. // "type": "string"
  3509. // }
  3510. // },
  3511. // "path": "v1/userProfiles/{userId}",
  3512. // "response": {
  3513. // "$ref": "UserProfile"
  3514. // },
  3515. // "scopes": [
  3516. // "https://www.googleapis.com/auth/classroom.profile.emails",
  3517. // "https://www.googleapis.com/auth/classroom.profile.photos",
  3518. // "https://www.googleapis.com/auth/classroom.rosters",
  3519. // "https://www.googleapis.com/auth/classroom.rosters.readonly"
  3520. // ]
  3521. // }
  3522. }