gmail-gen.go 190 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040
  1. // Package gmail provides access to the Gmail API.
  2. //
  3. // See https://developers.google.com/gmail/api/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/gmail/v1"
  8. // ...
  9. // gmailService, err := gmail.New(oauthHttpClient)
  10. package gmail // import "google.golang.org/api/gmail/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 = "gmail:v1"
  41. const apiName = "gmail"
  42. const apiVersion = "v1"
  43. const basePath = "https://www.googleapis.com/gmail/v1/users/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your mail
  47. MailGoogleComScope = "https://mail.google.com/"
  48. // Manage drafts and send emails
  49. GmailComposeScope = "https://www.googleapis.com/auth/gmail.compose"
  50. // Insert mail into your mailbox
  51. GmailInsertScope = "https://www.googleapis.com/auth/gmail.insert"
  52. // Manage mailbox labels
  53. GmailLabelsScope = "https://www.googleapis.com/auth/gmail.labels"
  54. // View and modify but not delete your email
  55. GmailModifyScope = "https://www.googleapis.com/auth/gmail.modify"
  56. // View your emails messages and settings
  57. GmailReadonlyScope = "https://www.googleapis.com/auth/gmail.readonly"
  58. // Send email on your behalf
  59. GmailSendScope = "https://www.googleapis.com/auth/gmail.send"
  60. )
  61. func New(client *http.Client) (*Service, error) {
  62. if client == nil {
  63. return nil, errors.New("client is nil")
  64. }
  65. s := &Service{client: client, BasePath: basePath}
  66. s.Users = NewUsersService(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. Users *UsersService
  74. }
  75. func (s *Service) userAgent() string {
  76. if s.UserAgent == "" {
  77. return googleapi.UserAgent
  78. }
  79. return googleapi.UserAgent + " " + s.UserAgent
  80. }
  81. func NewUsersService(s *Service) *UsersService {
  82. rs := &UsersService{s: s}
  83. rs.Drafts = NewUsersDraftsService(s)
  84. rs.History = NewUsersHistoryService(s)
  85. rs.Labels = NewUsersLabelsService(s)
  86. rs.Messages = NewUsersMessagesService(s)
  87. rs.Threads = NewUsersThreadsService(s)
  88. return rs
  89. }
  90. type UsersService struct {
  91. s *Service
  92. Drafts *UsersDraftsService
  93. History *UsersHistoryService
  94. Labels *UsersLabelsService
  95. Messages *UsersMessagesService
  96. Threads *UsersThreadsService
  97. }
  98. func NewUsersDraftsService(s *Service) *UsersDraftsService {
  99. rs := &UsersDraftsService{s: s}
  100. return rs
  101. }
  102. type UsersDraftsService struct {
  103. s *Service
  104. }
  105. func NewUsersHistoryService(s *Service) *UsersHistoryService {
  106. rs := &UsersHistoryService{s: s}
  107. return rs
  108. }
  109. type UsersHistoryService struct {
  110. s *Service
  111. }
  112. func NewUsersLabelsService(s *Service) *UsersLabelsService {
  113. rs := &UsersLabelsService{s: s}
  114. return rs
  115. }
  116. type UsersLabelsService struct {
  117. s *Service
  118. }
  119. func NewUsersMessagesService(s *Service) *UsersMessagesService {
  120. rs := &UsersMessagesService{s: s}
  121. rs.Attachments = NewUsersMessagesAttachmentsService(s)
  122. return rs
  123. }
  124. type UsersMessagesService struct {
  125. s *Service
  126. Attachments *UsersMessagesAttachmentsService
  127. }
  128. func NewUsersMessagesAttachmentsService(s *Service) *UsersMessagesAttachmentsService {
  129. rs := &UsersMessagesAttachmentsService{s: s}
  130. return rs
  131. }
  132. type UsersMessagesAttachmentsService struct {
  133. s *Service
  134. }
  135. func NewUsersThreadsService(s *Service) *UsersThreadsService {
  136. rs := &UsersThreadsService{s: s}
  137. return rs
  138. }
  139. type UsersThreadsService struct {
  140. s *Service
  141. }
  142. // Draft: A draft email in the user's mailbox.
  143. type Draft struct {
  144. // Id: The immutable ID of the draft.
  145. Id string `json:"id,omitempty"`
  146. // Message: The message content of the draft.
  147. Message *Message `json:"message,omitempty"`
  148. // ServerResponse contains the HTTP response code and headers from the
  149. // server.
  150. googleapi.ServerResponse `json:"-"`
  151. // ForceSendFields is a list of field names (e.g. "Id") to
  152. // unconditionally include in API requests. By default, fields with
  153. // empty values are omitted from API requests. However, any non-pointer,
  154. // non-interface field appearing in ForceSendFields will be sent to the
  155. // server regardless of whether the field is empty or not. This may be
  156. // used to include empty fields in Patch requests.
  157. ForceSendFields []string `json:"-"`
  158. }
  159. func (s *Draft) MarshalJSON() ([]byte, error) {
  160. type noMethod Draft
  161. raw := noMethod(*s)
  162. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  163. }
  164. // History: A record of a change to the user's mailbox. Each history
  165. // change may affect multiple messages in multiple ways.
  166. type History struct {
  167. // Id: The mailbox sequence ID.
  168. Id uint64 `json:"id,omitempty,string"`
  169. // LabelsAdded: Labels added to messages in this history record.
  170. LabelsAdded []*HistoryLabelAdded `json:"labelsAdded,omitempty"`
  171. // LabelsRemoved: Labels removed from messages in this history record.
  172. LabelsRemoved []*HistoryLabelRemoved `json:"labelsRemoved,omitempty"`
  173. // Messages: List of messages changed in this history record. The fields
  174. // for specific change types, such as messagesAdded may duplicate
  175. // messages in this field. We recommend using the specific change-type
  176. // fields instead of this.
  177. Messages []*Message `json:"messages,omitempty"`
  178. // MessagesAdded: Messages added to the mailbox in this history record.
  179. MessagesAdded []*HistoryMessageAdded `json:"messagesAdded,omitempty"`
  180. // MessagesDeleted: Messages deleted (not Trashed) from the mailbox in
  181. // this history record.
  182. MessagesDeleted []*HistoryMessageDeleted `json:"messagesDeleted,omitempty"`
  183. // ForceSendFields is a list of field names (e.g. "Id") to
  184. // unconditionally include in API requests. By default, fields with
  185. // empty values are omitted from API requests. However, any non-pointer,
  186. // non-interface field appearing in ForceSendFields will be sent to the
  187. // server regardless of whether the field is empty or not. This may be
  188. // used to include empty fields in Patch requests.
  189. ForceSendFields []string `json:"-"`
  190. }
  191. func (s *History) MarshalJSON() ([]byte, error) {
  192. type noMethod History
  193. raw := noMethod(*s)
  194. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  195. }
  196. type HistoryLabelAdded struct {
  197. // LabelIds: Label IDs added to the message.
  198. LabelIds []string `json:"labelIds,omitempty"`
  199. Message *Message `json:"message,omitempty"`
  200. // ForceSendFields is a list of field names (e.g. "LabelIds") to
  201. // unconditionally include in API requests. By default, fields with
  202. // empty values are omitted from API requests. However, any non-pointer,
  203. // non-interface field appearing in ForceSendFields will be sent to the
  204. // server regardless of whether the field is empty or not. This may be
  205. // used to include empty fields in Patch requests.
  206. ForceSendFields []string `json:"-"`
  207. }
  208. func (s *HistoryLabelAdded) MarshalJSON() ([]byte, error) {
  209. type noMethod HistoryLabelAdded
  210. raw := noMethod(*s)
  211. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  212. }
  213. type HistoryLabelRemoved struct {
  214. // LabelIds: Label IDs removed from the message.
  215. LabelIds []string `json:"labelIds,omitempty"`
  216. Message *Message `json:"message,omitempty"`
  217. // ForceSendFields is a list of field names (e.g. "LabelIds") to
  218. // unconditionally include in API requests. By default, fields with
  219. // empty values are omitted from API requests. However, any non-pointer,
  220. // non-interface field appearing in ForceSendFields will be sent to the
  221. // server regardless of whether the field is empty or not. This may be
  222. // used to include empty fields in Patch requests.
  223. ForceSendFields []string `json:"-"`
  224. }
  225. func (s *HistoryLabelRemoved) MarshalJSON() ([]byte, error) {
  226. type noMethod HistoryLabelRemoved
  227. raw := noMethod(*s)
  228. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  229. }
  230. type HistoryMessageAdded struct {
  231. Message *Message `json:"message,omitempty"`
  232. // ForceSendFields is a list of field names (e.g. "Message") to
  233. // unconditionally include in API requests. By default, fields with
  234. // empty values are omitted from API requests. However, any non-pointer,
  235. // non-interface field appearing in ForceSendFields will be sent to the
  236. // server regardless of whether the field is empty or not. This may be
  237. // used to include empty fields in Patch requests.
  238. ForceSendFields []string `json:"-"`
  239. }
  240. func (s *HistoryMessageAdded) MarshalJSON() ([]byte, error) {
  241. type noMethod HistoryMessageAdded
  242. raw := noMethod(*s)
  243. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  244. }
  245. type HistoryMessageDeleted struct {
  246. Message *Message `json:"message,omitempty"`
  247. // ForceSendFields is a list of field names (e.g. "Message") to
  248. // unconditionally include in API requests. By default, fields with
  249. // empty values are omitted from API requests. However, any non-pointer,
  250. // non-interface field appearing in ForceSendFields will be sent to the
  251. // server regardless of whether the field is empty or not. This may be
  252. // used to include empty fields in Patch requests.
  253. ForceSendFields []string `json:"-"`
  254. }
  255. func (s *HistoryMessageDeleted) MarshalJSON() ([]byte, error) {
  256. type noMethod HistoryMessageDeleted
  257. raw := noMethod(*s)
  258. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  259. }
  260. // Label: Labels are used to categorize messages and threads within the
  261. // user's mailbox.
  262. type Label struct {
  263. // Id: The immutable ID of the label.
  264. Id string `json:"id,omitempty"`
  265. // LabelListVisibility: The visibility of the label in the label list in
  266. // the Gmail web interface.
  267. //
  268. // Possible values:
  269. // "labelHide"
  270. // "labelShow"
  271. // "labelShowIfUnread"
  272. LabelListVisibility string `json:"labelListVisibility,omitempty"`
  273. // MessageListVisibility: The visibility of the label in the message
  274. // list in the Gmail web interface.
  275. //
  276. // Possible values:
  277. // "hide"
  278. // "show"
  279. MessageListVisibility string `json:"messageListVisibility,omitempty"`
  280. // MessagesTotal: The total number of messages with the label.
  281. MessagesTotal int64 `json:"messagesTotal,omitempty"`
  282. // MessagesUnread: The number of unread messages with the label.
  283. MessagesUnread int64 `json:"messagesUnread,omitempty"`
  284. // Name: The display name of the label.
  285. Name string `json:"name,omitempty"`
  286. // ThreadsTotal: The total number of threads with the label.
  287. ThreadsTotal int64 `json:"threadsTotal,omitempty"`
  288. // ThreadsUnread: The number of unread threads with the label.
  289. ThreadsUnread int64 `json:"threadsUnread,omitempty"`
  290. // Type: The owner type for the label. User labels are created by the
  291. // user and can be modified and deleted by the user and can be applied
  292. // to any message or thread. System labels are internally created and
  293. // cannot be added, modified, or deleted. System labels may be able to
  294. // be applied to or removed from messages and threads under some
  295. // circumstances but this is not guaranteed. For example, users can
  296. // apply and remove the INBOX and UNREAD labels from messages and
  297. // threads, but cannot apply or remove the DRAFTS or SENT labels from
  298. // messages or threads.
  299. //
  300. // Possible values:
  301. // "system"
  302. // "user"
  303. Type string `json:"type,omitempty"`
  304. // ServerResponse contains the HTTP response code and headers from the
  305. // server.
  306. googleapi.ServerResponse `json:"-"`
  307. // ForceSendFields is a list of field names (e.g. "Id") to
  308. // unconditionally include in API requests. By default, fields with
  309. // empty values are omitted from API requests. However, any non-pointer,
  310. // non-interface field appearing in ForceSendFields will be sent to the
  311. // server regardless of whether the field is empty or not. This may be
  312. // used to include empty fields in Patch requests.
  313. ForceSendFields []string `json:"-"`
  314. }
  315. func (s *Label) MarshalJSON() ([]byte, error) {
  316. type noMethod Label
  317. raw := noMethod(*s)
  318. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  319. }
  320. type ListDraftsResponse struct {
  321. // Drafts: List of drafts.
  322. Drafts []*Draft `json:"drafts,omitempty"`
  323. // NextPageToken: Token to retrieve the next page of results in the
  324. // list.
  325. NextPageToken string `json:"nextPageToken,omitempty"`
  326. // ResultSizeEstimate: Estimated total number of results.
  327. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  328. // ServerResponse contains the HTTP response code and headers from the
  329. // server.
  330. googleapi.ServerResponse `json:"-"`
  331. // ForceSendFields is a list of field names (e.g. "Drafts") to
  332. // unconditionally include in API requests. By default, fields with
  333. // empty values are omitted from API requests. However, any non-pointer,
  334. // non-interface field appearing in ForceSendFields will be sent to the
  335. // server regardless of whether the field is empty or not. This may be
  336. // used to include empty fields in Patch requests.
  337. ForceSendFields []string `json:"-"`
  338. }
  339. func (s *ListDraftsResponse) MarshalJSON() ([]byte, error) {
  340. type noMethod ListDraftsResponse
  341. raw := noMethod(*s)
  342. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  343. }
  344. type ListHistoryResponse struct {
  345. // History: List of history records. Any messages contained in the
  346. // response will typically only have id and threadId fields populated.
  347. History []*History `json:"history,omitempty"`
  348. // HistoryId: The ID of the mailbox's current history record.
  349. HistoryId uint64 `json:"historyId,omitempty,string"`
  350. // NextPageToken: Page token to retrieve the next page of results in the
  351. // list.
  352. NextPageToken string `json:"nextPageToken,omitempty"`
  353. // ServerResponse contains the HTTP response code and headers from the
  354. // server.
  355. googleapi.ServerResponse `json:"-"`
  356. // ForceSendFields is a list of field names (e.g. "History") to
  357. // unconditionally include in API requests. By default, fields with
  358. // empty values are omitted from API requests. However, any non-pointer,
  359. // non-interface field appearing in ForceSendFields will be sent to the
  360. // server regardless of whether the field is empty or not. This may be
  361. // used to include empty fields in Patch requests.
  362. ForceSendFields []string `json:"-"`
  363. }
  364. func (s *ListHistoryResponse) MarshalJSON() ([]byte, error) {
  365. type noMethod ListHistoryResponse
  366. raw := noMethod(*s)
  367. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  368. }
  369. type ListLabelsResponse struct {
  370. // Labels: List of labels.
  371. Labels []*Label `json:"labels,omitempty"`
  372. // ServerResponse contains the HTTP response code and headers from the
  373. // server.
  374. googleapi.ServerResponse `json:"-"`
  375. // ForceSendFields is a list of field names (e.g. "Labels") to
  376. // unconditionally include in API requests. By default, fields with
  377. // empty values are omitted from API requests. However, any non-pointer,
  378. // non-interface field appearing in ForceSendFields will be sent to the
  379. // server regardless of whether the field is empty or not. This may be
  380. // used to include empty fields in Patch requests.
  381. ForceSendFields []string `json:"-"`
  382. }
  383. func (s *ListLabelsResponse) MarshalJSON() ([]byte, error) {
  384. type noMethod ListLabelsResponse
  385. raw := noMethod(*s)
  386. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  387. }
  388. type ListMessagesResponse struct {
  389. // Messages: List of messages.
  390. Messages []*Message `json:"messages,omitempty"`
  391. // NextPageToken: Token to retrieve the next page of results in the
  392. // list.
  393. NextPageToken string `json:"nextPageToken,omitempty"`
  394. // ResultSizeEstimate: Estimated total number of results.
  395. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  396. // ServerResponse contains the HTTP response code and headers from the
  397. // server.
  398. googleapi.ServerResponse `json:"-"`
  399. // ForceSendFields is a list of field names (e.g. "Messages") to
  400. // unconditionally include in API requests. By default, fields with
  401. // empty values are omitted from API requests. However, any non-pointer,
  402. // non-interface field appearing in ForceSendFields will be sent to the
  403. // server regardless of whether the field is empty or not. This may be
  404. // used to include empty fields in Patch requests.
  405. ForceSendFields []string `json:"-"`
  406. }
  407. func (s *ListMessagesResponse) MarshalJSON() ([]byte, error) {
  408. type noMethod ListMessagesResponse
  409. raw := noMethod(*s)
  410. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  411. }
  412. type ListThreadsResponse struct {
  413. // NextPageToken: Page token to retrieve the next page of results in the
  414. // list.
  415. NextPageToken string `json:"nextPageToken,omitempty"`
  416. // ResultSizeEstimate: Estimated total number of results.
  417. ResultSizeEstimate int64 `json:"resultSizeEstimate,omitempty"`
  418. // Threads: List of threads.
  419. Threads []*Thread `json:"threads,omitempty"`
  420. // ServerResponse contains the HTTP response code and headers from the
  421. // server.
  422. googleapi.ServerResponse `json:"-"`
  423. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  424. // unconditionally include in API requests. By default, fields with
  425. // empty values are omitted from API requests. However, any non-pointer,
  426. // non-interface field appearing in ForceSendFields will be sent to the
  427. // server regardless of whether the field is empty or not. This may be
  428. // used to include empty fields in Patch requests.
  429. ForceSendFields []string `json:"-"`
  430. }
  431. func (s *ListThreadsResponse) MarshalJSON() ([]byte, error) {
  432. type noMethod ListThreadsResponse
  433. raw := noMethod(*s)
  434. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  435. }
  436. // Message: An email message.
  437. type Message struct {
  438. // HistoryId: The ID of the last history record that modified this
  439. // message.
  440. HistoryId uint64 `json:"historyId,omitempty,string"`
  441. // Id: The immutable ID of the message.
  442. Id string `json:"id,omitempty"`
  443. // InternalDate: The internal message creation timestamp (epoch ms),
  444. // which determines ordering in the inbox. For normal SMTP-received
  445. // email, this represents the time the message was originally accepted
  446. // by Google, which is more reliable than the Date header. However, for
  447. // API-migrated mail, it can be configured by client to be based on the
  448. // Date header.
  449. InternalDate int64 `json:"internalDate,omitempty,string"`
  450. // LabelIds: List of IDs of labels applied to this message.
  451. LabelIds []string `json:"labelIds,omitempty"`
  452. // Payload: The parsed email structure in the message parts.
  453. Payload *MessagePart `json:"payload,omitempty"`
  454. // Raw: The entire email message in an RFC 2822 formatted and base64url
  455. // encoded string. Returned in messages.get and drafts.get responses
  456. // when the format=RAW parameter is supplied.
  457. Raw string `json:"raw,omitempty"`
  458. // SizeEstimate: Estimated size in bytes of the message.
  459. SizeEstimate int64 `json:"sizeEstimate,omitempty"`
  460. // Snippet: A short part of the message text.
  461. Snippet string `json:"snippet,omitempty"`
  462. // ThreadId: The ID of the thread the message belongs to. To add a
  463. // message or draft to a thread, the following criteria must be met:
  464. // - The requested threadId must be specified on the Message or
  465. // Draft.Message you supply with your request.
  466. // - The References and In-Reply-To headers must be set in compliance
  467. // with the RFC 2822 standard.
  468. // - The Subject headers must match.
  469. ThreadId string `json:"threadId,omitempty"`
  470. // ServerResponse contains the HTTP response code and headers from the
  471. // server.
  472. googleapi.ServerResponse `json:"-"`
  473. // ForceSendFields is a list of field names (e.g. "HistoryId") to
  474. // unconditionally include in API requests. By default, fields with
  475. // empty values are omitted from API requests. However, any non-pointer,
  476. // non-interface field appearing in ForceSendFields will be sent to the
  477. // server regardless of whether the field is empty or not. This may be
  478. // used to include empty fields in Patch requests.
  479. ForceSendFields []string `json:"-"`
  480. }
  481. func (s *Message) MarshalJSON() ([]byte, error) {
  482. type noMethod Message
  483. raw := noMethod(*s)
  484. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  485. }
  486. // MessagePart: A single MIME message part.
  487. type MessagePart struct {
  488. // Body: The message part body for this part, which may be empty for
  489. // container MIME message parts.
  490. Body *MessagePartBody `json:"body,omitempty"`
  491. // Filename: The filename of the attachment. Only present if this
  492. // message part represents an attachment.
  493. Filename string `json:"filename,omitempty"`
  494. // Headers: List of headers on this message part. For the top-level
  495. // message part, representing the entire message payload, it will
  496. // contain the standard RFC 2822 email headers such as To, From, and
  497. // Subject.
  498. Headers []*MessagePartHeader `json:"headers,omitempty"`
  499. // MimeType: The MIME type of the message part.
  500. MimeType string `json:"mimeType,omitempty"`
  501. // PartId: The immutable ID of the message part.
  502. PartId string `json:"partId,omitempty"`
  503. // Parts: The child MIME message parts of this part. This only applies
  504. // to container MIME message parts, for example multipart/*. For non-
  505. // container MIME message part types, such as text/plain, this field is
  506. // empty. For more information, see RFC 1521.
  507. Parts []*MessagePart `json:"parts,omitempty"`
  508. // ForceSendFields is a list of field names (e.g. "Body") to
  509. // unconditionally include in API requests. By default, fields with
  510. // empty values are omitted from API requests. However, any non-pointer,
  511. // non-interface field appearing in ForceSendFields will be sent to the
  512. // server regardless of whether the field is empty or not. This may be
  513. // used to include empty fields in Patch requests.
  514. ForceSendFields []string `json:"-"`
  515. }
  516. func (s *MessagePart) MarshalJSON() ([]byte, error) {
  517. type noMethod MessagePart
  518. raw := noMethod(*s)
  519. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  520. }
  521. // MessagePartBody: The body of a single MIME message part.
  522. type MessagePartBody struct {
  523. // AttachmentId: When present, contains the ID of an external attachment
  524. // that can be retrieved in a separate messages.attachments.get request.
  525. // When not present, the entire content of the message part body is
  526. // contained in the data field.
  527. AttachmentId string `json:"attachmentId,omitempty"`
  528. // Data: The body data of a MIME message part. May be empty for MIME
  529. // container types that have no message body or when the body data is
  530. // sent as a separate attachment. An attachment ID is present if the
  531. // body data is contained in a separate attachment.
  532. Data string `json:"data,omitempty"`
  533. // Size: Total number of bytes in the body of the message part.
  534. Size int64 `json:"size,omitempty"`
  535. // ServerResponse contains the HTTP response code and headers from the
  536. // server.
  537. googleapi.ServerResponse `json:"-"`
  538. // ForceSendFields is a list of field names (e.g. "AttachmentId") to
  539. // unconditionally include in API requests. By default, fields with
  540. // empty values are omitted from API requests. However, any non-pointer,
  541. // non-interface field appearing in ForceSendFields will be sent to the
  542. // server regardless of whether the field is empty or not. This may be
  543. // used to include empty fields in Patch requests.
  544. ForceSendFields []string `json:"-"`
  545. }
  546. func (s *MessagePartBody) MarshalJSON() ([]byte, error) {
  547. type noMethod MessagePartBody
  548. raw := noMethod(*s)
  549. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  550. }
  551. type MessagePartHeader struct {
  552. // Name: The name of the header before the : separator. For example, To.
  553. Name string `json:"name,omitempty"`
  554. // Value: The value of the header after the : separator. For example,
  555. // someuser@example.com.
  556. Value string `json:"value,omitempty"`
  557. // ForceSendFields is a list of field names (e.g. "Name") to
  558. // unconditionally include in API requests. By default, fields with
  559. // empty values are omitted from API requests. However, any non-pointer,
  560. // non-interface field appearing in ForceSendFields will be sent to the
  561. // server regardless of whether the field is empty or not. This may be
  562. // used to include empty fields in Patch requests.
  563. ForceSendFields []string `json:"-"`
  564. }
  565. func (s *MessagePartHeader) MarshalJSON() ([]byte, error) {
  566. type noMethod MessagePartHeader
  567. raw := noMethod(*s)
  568. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  569. }
  570. type ModifyMessageRequest struct {
  571. // AddLabelIds: A list of IDs of labels to add to this message.
  572. AddLabelIds []string `json:"addLabelIds,omitempty"`
  573. // RemoveLabelIds: A list IDs of labels to remove from this message.
  574. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  575. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  576. // unconditionally include in API requests. By default, fields with
  577. // empty values are omitted from API requests. However, any non-pointer,
  578. // non-interface field appearing in ForceSendFields will be sent to the
  579. // server regardless of whether the field is empty or not. This may be
  580. // used to include empty fields in Patch requests.
  581. ForceSendFields []string `json:"-"`
  582. }
  583. func (s *ModifyMessageRequest) MarshalJSON() ([]byte, error) {
  584. type noMethod ModifyMessageRequest
  585. raw := noMethod(*s)
  586. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  587. }
  588. type ModifyThreadRequest struct {
  589. // AddLabelIds: A list of IDs of labels to add to this thread.
  590. AddLabelIds []string `json:"addLabelIds,omitempty"`
  591. // RemoveLabelIds: A list of IDs of labels to remove from this thread.
  592. RemoveLabelIds []string `json:"removeLabelIds,omitempty"`
  593. // ForceSendFields is a list of field names (e.g. "AddLabelIds") to
  594. // unconditionally include in API requests. By default, fields with
  595. // empty values are omitted from API requests. However, any non-pointer,
  596. // non-interface field appearing in ForceSendFields will be sent to the
  597. // server regardless of whether the field is empty or not. This may be
  598. // used to include empty fields in Patch requests.
  599. ForceSendFields []string `json:"-"`
  600. }
  601. func (s *ModifyThreadRequest) MarshalJSON() ([]byte, error) {
  602. type noMethod ModifyThreadRequest
  603. raw := noMethod(*s)
  604. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  605. }
  606. // Profile: Profile for a Gmail user.
  607. type Profile struct {
  608. // EmailAddress: The user's email address.
  609. EmailAddress string `json:"emailAddress,omitempty"`
  610. // HistoryId: The ID of the mailbox's current history record.
  611. HistoryId uint64 `json:"historyId,omitempty,string"`
  612. // MessagesTotal: The total number of messages in the mailbox.
  613. MessagesTotal int64 `json:"messagesTotal,omitempty"`
  614. // ThreadsTotal: The total number of threads in the mailbox.
  615. ThreadsTotal int64 `json:"threadsTotal,omitempty"`
  616. // ServerResponse contains the HTTP response code and headers from the
  617. // server.
  618. googleapi.ServerResponse `json:"-"`
  619. // ForceSendFields is a list of field names (e.g. "EmailAddress") to
  620. // unconditionally include in API requests. By default, fields with
  621. // empty values are omitted from API requests. However, any non-pointer,
  622. // non-interface field appearing in ForceSendFields will be sent to the
  623. // server regardless of whether the field is empty or not. This may be
  624. // used to include empty fields in Patch requests.
  625. ForceSendFields []string `json:"-"`
  626. }
  627. func (s *Profile) MarshalJSON() ([]byte, error) {
  628. type noMethod Profile
  629. raw := noMethod(*s)
  630. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  631. }
  632. // Thread: A collection of messages representing a conversation.
  633. type Thread struct {
  634. // HistoryId: The ID of the last history record that modified this
  635. // thread.
  636. HistoryId uint64 `json:"historyId,omitempty,string"`
  637. // Id: The unique ID of the thread.
  638. Id string `json:"id,omitempty"`
  639. // Messages: The list of messages in the thread.
  640. Messages []*Message `json:"messages,omitempty"`
  641. // Snippet: A short part of the message text.
  642. Snippet string `json:"snippet,omitempty"`
  643. // ServerResponse contains the HTTP response code and headers from the
  644. // server.
  645. googleapi.ServerResponse `json:"-"`
  646. // ForceSendFields is a list of field names (e.g. "HistoryId") to
  647. // unconditionally include in API requests. By default, fields with
  648. // empty values are omitted from API requests. However, any non-pointer,
  649. // non-interface field appearing in ForceSendFields will be sent to the
  650. // server regardless of whether the field is empty or not. This may be
  651. // used to include empty fields in Patch requests.
  652. ForceSendFields []string `json:"-"`
  653. }
  654. func (s *Thread) MarshalJSON() ([]byte, error) {
  655. type noMethod Thread
  656. raw := noMethod(*s)
  657. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  658. }
  659. // WatchRequest: Set up or update a new push notification watch on this
  660. // user's mailbox.
  661. type WatchRequest struct {
  662. // LabelFilterAction: Filtering behavior of labelIds list specified.
  663. //
  664. // Possible values:
  665. // "exclude"
  666. // "include"
  667. LabelFilterAction string `json:"labelFilterAction,omitempty"`
  668. // LabelIds: List of label_ids to restrict notifications about. By
  669. // default, if unspecified, all changes are pushed out. If specified
  670. // then dictates which labels are required for a push notification to be
  671. // generated.
  672. LabelIds []string `json:"labelIds,omitempty"`
  673. // TopicName: A fully qualified Google Cloud Pub/Sub API topic name to
  674. // publish the events to. This topic name **must** already exist in
  675. // Cloud Pub/Sub and you **must** have already granted gmail "publish"
  676. // permission on it. For example,
  677. // "projects/my-project-identifier/topics/my-topic-name" (using the
  678. // Cloud Pub/Sub "v1" topic naming format).
  679. //
  680. // Note that the "my-project-identifier" portion must exactly match your
  681. // Google developer project id (the one executing this watch request).
  682. TopicName string `json:"topicName,omitempty"`
  683. // ForceSendFields is a list of field names (e.g. "LabelFilterAction")
  684. // to unconditionally include in API requests. By default, fields with
  685. // empty values are omitted from API requests. However, any non-pointer,
  686. // non-interface field appearing in ForceSendFields will be sent to the
  687. // server regardless of whether the field is empty or not. This may be
  688. // used to include empty fields in Patch requests.
  689. ForceSendFields []string `json:"-"`
  690. }
  691. func (s *WatchRequest) MarshalJSON() ([]byte, error) {
  692. type noMethod WatchRequest
  693. raw := noMethod(*s)
  694. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  695. }
  696. // WatchResponse: Push notification watch response.
  697. type WatchResponse struct {
  698. // Expiration: When Gmail will stop sending notifications for mailbox
  699. // updates (epoch millis). Call watch again before this time to renew
  700. // the watch.
  701. Expiration int64 `json:"expiration,omitempty,string"`
  702. // HistoryId: The ID of the mailbox's current history record.
  703. HistoryId uint64 `json:"historyId,omitempty,string"`
  704. // ServerResponse contains the HTTP response code and headers from the
  705. // server.
  706. googleapi.ServerResponse `json:"-"`
  707. // ForceSendFields is a list of field names (e.g. "Expiration") to
  708. // unconditionally include in API requests. By default, fields with
  709. // empty values are omitted from API requests. However, any non-pointer,
  710. // non-interface field appearing in ForceSendFields will be sent to the
  711. // server regardless of whether the field is empty or not. This may be
  712. // used to include empty fields in Patch requests.
  713. ForceSendFields []string `json:"-"`
  714. }
  715. func (s *WatchResponse) MarshalJSON() ([]byte, error) {
  716. type noMethod WatchResponse
  717. raw := noMethod(*s)
  718. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  719. }
  720. // method id "gmail.users.getProfile":
  721. type UsersGetProfileCall struct {
  722. s *Service
  723. userId string
  724. urlParams_ gensupport.URLParams
  725. ifNoneMatch_ string
  726. ctx_ context.Context
  727. }
  728. // GetProfile: Gets the current user's Gmail profile.
  729. func (r *UsersService) GetProfile(userId string) *UsersGetProfileCall {
  730. c := &UsersGetProfileCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  731. c.userId = userId
  732. return c
  733. }
  734. // Fields allows partial responses to be retrieved. See
  735. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  736. // for more information.
  737. func (c *UsersGetProfileCall) Fields(s ...googleapi.Field) *UsersGetProfileCall {
  738. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  739. return c
  740. }
  741. // IfNoneMatch sets the optional parameter which makes the operation
  742. // fail if the object's ETag matches the given value. This is useful for
  743. // getting updates only after the object has changed since the last
  744. // request. Use googleapi.IsNotModified to check whether the response
  745. // error from Do is the result of In-None-Match.
  746. func (c *UsersGetProfileCall) IfNoneMatch(entityTag string) *UsersGetProfileCall {
  747. c.ifNoneMatch_ = entityTag
  748. return c
  749. }
  750. // Context sets the context to be used in this call's Do method. Any
  751. // pending HTTP request will be aborted if the provided context is
  752. // canceled.
  753. func (c *UsersGetProfileCall) Context(ctx context.Context) *UsersGetProfileCall {
  754. c.ctx_ = ctx
  755. return c
  756. }
  757. func (c *UsersGetProfileCall) doRequest(alt string) (*http.Response, error) {
  758. var body io.Reader = nil
  759. c.urlParams_.Set("alt", alt)
  760. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/profile")
  761. urls += "?" + c.urlParams_.Encode()
  762. req, _ := http.NewRequest("GET", urls, body)
  763. googleapi.Expand(req.URL, map[string]string{
  764. "userId": c.userId,
  765. })
  766. req.Header.Set("User-Agent", c.s.userAgent())
  767. if c.ifNoneMatch_ != "" {
  768. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  769. }
  770. if c.ctx_ != nil {
  771. return ctxhttp.Do(c.ctx_, c.s.client, req)
  772. }
  773. return c.s.client.Do(req)
  774. }
  775. // Do executes the "gmail.users.getProfile" call.
  776. // Exactly one of *Profile or error will be non-nil. Any non-2xx status
  777. // code is an error. Response headers are in either
  778. // *Profile.ServerResponse.Header or (if a response was returned at all)
  779. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  780. // check whether the returned error was because http.StatusNotModified
  781. // was returned.
  782. func (c *UsersGetProfileCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
  783. gensupport.SetOptions(c.urlParams_, opts...)
  784. res, err := c.doRequest("json")
  785. if res != nil && res.StatusCode == http.StatusNotModified {
  786. if res.Body != nil {
  787. res.Body.Close()
  788. }
  789. return nil, &googleapi.Error{
  790. Code: res.StatusCode,
  791. Header: res.Header,
  792. }
  793. }
  794. if err != nil {
  795. return nil, err
  796. }
  797. defer googleapi.CloseBody(res)
  798. if err := googleapi.CheckResponse(res); err != nil {
  799. return nil, err
  800. }
  801. ret := &Profile{
  802. ServerResponse: googleapi.ServerResponse{
  803. Header: res.Header,
  804. HTTPStatusCode: res.StatusCode,
  805. },
  806. }
  807. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  808. return nil, err
  809. }
  810. return ret, nil
  811. // {
  812. // "description": "Gets the current user's Gmail profile.",
  813. // "httpMethod": "GET",
  814. // "id": "gmail.users.getProfile",
  815. // "parameterOrder": [
  816. // "userId"
  817. // ],
  818. // "parameters": {
  819. // "userId": {
  820. // "default": "me",
  821. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  822. // "location": "path",
  823. // "required": true,
  824. // "type": "string"
  825. // }
  826. // },
  827. // "path": "{userId}/profile",
  828. // "response": {
  829. // "$ref": "Profile"
  830. // },
  831. // "scopes": [
  832. // "https://mail.google.com/",
  833. // "https://www.googleapis.com/auth/gmail.compose",
  834. // "https://www.googleapis.com/auth/gmail.modify",
  835. // "https://www.googleapis.com/auth/gmail.readonly"
  836. // ]
  837. // }
  838. }
  839. // method id "gmail.users.stop":
  840. type UsersStopCall struct {
  841. s *Service
  842. userId string
  843. urlParams_ gensupport.URLParams
  844. ctx_ context.Context
  845. }
  846. // Stop: Stop receiving push notifications for the given user mailbox.
  847. func (r *UsersService) Stop(userId string) *UsersStopCall {
  848. c := &UsersStopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  849. c.userId = userId
  850. return c
  851. }
  852. // Fields allows partial responses to be retrieved. See
  853. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  854. // for more information.
  855. func (c *UsersStopCall) Fields(s ...googleapi.Field) *UsersStopCall {
  856. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  857. return c
  858. }
  859. // Context sets the context to be used in this call's Do method. Any
  860. // pending HTTP request will be aborted if the provided context is
  861. // canceled.
  862. func (c *UsersStopCall) Context(ctx context.Context) *UsersStopCall {
  863. c.ctx_ = ctx
  864. return c
  865. }
  866. func (c *UsersStopCall) doRequest(alt string) (*http.Response, error) {
  867. var body io.Reader = nil
  868. c.urlParams_.Set("alt", alt)
  869. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/stop")
  870. urls += "?" + c.urlParams_.Encode()
  871. req, _ := http.NewRequest("POST", urls, body)
  872. googleapi.Expand(req.URL, map[string]string{
  873. "userId": c.userId,
  874. })
  875. req.Header.Set("User-Agent", c.s.userAgent())
  876. if c.ctx_ != nil {
  877. return ctxhttp.Do(c.ctx_, c.s.client, req)
  878. }
  879. return c.s.client.Do(req)
  880. }
  881. // Do executes the "gmail.users.stop" call.
  882. func (c *UsersStopCall) Do(opts ...googleapi.CallOption) error {
  883. gensupport.SetOptions(c.urlParams_, opts...)
  884. res, err := c.doRequest("json")
  885. if err != nil {
  886. return err
  887. }
  888. defer googleapi.CloseBody(res)
  889. if err := googleapi.CheckResponse(res); err != nil {
  890. return err
  891. }
  892. return nil
  893. // {
  894. // "description": "Stop receiving push notifications for the given user mailbox.",
  895. // "httpMethod": "POST",
  896. // "id": "gmail.users.stop",
  897. // "parameterOrder": [
  898. // "userId"
  899. // ],
  900. // "parameters": {
  901. // "userId": {
  902. // "default": "me",
  903. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  904. // "location": "path",
  905. // "required": true,
  906. // "type": "string"
  907. // }
  908. // },
  909. // "path": "{userId}/stop",
  910. // "scopes": [
  911. // "https://mail.google.com/",
  912. // "https://www.googleapis.com/auth/gmail.modify",
  913. // "https://www.googleapis.com/auth/gmail.readonly"
  914. // ]
  915. // }
  916. }
  917. // method id "gmail.users.watch":
  918. type UsersWatchCall struct {
  919. s *Service
  920. userId string
  921. watchrequest *WatchRequest
  922. urlParams_ gensupport.URLParams
  923. ctx_ context.Context
  924. }
  925. // Watch: Set up or update a push notification watch on the given user
  926. // mailbox.
  927. func (r *UsersService) Watch(userId string, watchrequest *WatchRequest) *UsersWatchCall {
  928. c := &UsersWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  929. c.userId = userId
  930. c.watchrequest = watchrequest
  931. return c
  932. }
  933. // Fields allows partial responses to be retrieved. See
  934. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  935. // for more information.
  936. func (c *UsersWatchCall) Fields(s ...googleapi.Field) *UsersWatchCall {
  937. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  938. return c
  939. }
  940. // Context sets the context to be used in this call's Do method. Any
  941. // pending HTTP request will be aborted if the provided context is
  942. // canceled.
  943. func (c *UsersWatchCall) Context(ctx context.Context) *UsersWatchCall {
  944. c.ctx_ = ctx
  945. return c
  946. }
  947. func (c *UsersWatchCall) doRequest(alt string) (*http.Response, error) {
  948. var body io.Reader = nil
  949. body, err := googleapi.WithoutDataWrapper.JSONReader(c.watchrequest)
  950. if err != nil {
  951. return nil, err
  952. }
  953. ctype := "application/json"
  954. c.urlParams_.Set("alt", alt)
  955. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/watch")
  956. urls += "?" + c.urlParams_.Encode()
  957. req, _ := http.NewRequest("POST", urls, body)
  958. googleapi.Expand(req.URL, map[string]string{
  959. "userId": c.userId,
  960. })
  961. req.Header.Set("Content-Type", ctype)
  962. req.Header.Set("User-Agent", c.s.userAgent())
  963. if c.ctx_ != nil {
  964. return ctxhttp.Do(c.ctx_, c.s.client, req)
  965. }
  966. return c.s.client.Do(req)
  967. }
  968. // Do executes the "gmail.users.watch" call.
  969. // Exactly one of *WatchResponse or error will be non-nil. Any non-2xx
  970. // status code is an error. Response headers are in either
  971. // *WatchResponse.ServerResponse.Header or (if a response was returned
  972. // at all) in error.(*googleapi.Error).Header. Use
  973. // googleapi.IsNotModified to check whether the returned error was
  974. // because http.StatusNotModified was returned.
  975. func (c *UsersWatchCall) Do(opts ...googleapi.CallOption) (*WatchResponse, error) {
  976. gensupport.SetOptions(c.urlParams_, opts...)
  977. res, err := c.doRequest("json")
  978. if res != nil && res.StatusCode == http.StatusNotModified {
  979. if res.Body != nil {
  980. res.Body.Close()
  981. }
  982. return nil, &googleapi.Error{
  983. Code: res.StatusCode,
  984. Header: res.Header,
  985. }
  986. }
  987. if err != nil {
  988. return nil, err
  989. }
  990. defer googleapi.CloseBody(res)
  991. if err := googleapi.CheckResponse(res); err != nil {
  992. return nil, err
  993. }
  994. ret := &WatchResponse{
  995. ServerResponse: googleapi.ServerResponse{
  996. Header: res.Header,
  997. HTTPStatusCode: res.StatusCode,
  998. },
  999. }
  1000. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1001. return nil, err
  1002. }
  1003. return ret, nil
  1004. // {
  1005. // "description": "Set up or update a push notification watch on the given user mailbox.",
  1006. // "httpMethod": "POST",
  1007. // "id": "gmail.users.watch",
  1008. // "parameterOrder": [
  1009. // "userId"
  1010. // ],
  1011. // "parameters": {
  1012. // "userId": {
  1013. // "default": "me",
  1014. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1015. // "location": "path",
  1016. // "required": true,
  1017. // "type": "string"
  1018. // }
  1019. // },
  1020. // "path": "{userId}/watch",
  1021. // "request": {
  1022. // "$ref": "WatchRequest"
  1023. // },
  1024. // "response": {
  1025. // "$ref": "WatchResponse"
  1026. // },
  1027. // "scopes": [
  1028. // "https://mail.google.com/",
  1029. // "https://www.googleapis.com/auth/gmail.modify",
  1030. // "https://www.googleapis.com/auth/gmail.readonly"
  1031. // ]
  1032. // }
  1033. }
  1034. // method id "gmail.users.drafts.create":
  1035. type UsersDraftsCreateCall struct {
  1036. s *Service
  1037. userId string
  1038. draft *Draft
  1039. urlParams_ gensupport.URLParams
  1040. media_ io.Reader
  1041. resumableBuffer_ *gensupport.ResumableBuffer
  1042. mediaType_ string
  1043. mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_.
  1044. progressUpdater_ googleapi.ProgressUpdater
  1045. ctx_ context.Context
  1046. }
  1047. // Create: Creates a new draft with the DRAFT label.
  1048. func (r *UsersDraftsService) Create(userId string, draft *Draft) *UsersDraftsCreateCall {
  1049. c := &UsersDraftsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1050. c.userId = userId
  1051. c.draft = draft
  1052. return c
  1053. }
  1054. // Media specifies the media to upload in one or more chunks. The chunk
  1055. // size may be controlled by supplying a MediaOption generated by
  1056. // googleapi.ChunkSize. The chunk size defaults to
  1057. // googleapi.DefaultUploadChunkSize.
  1058. // At most one of Media and ResumableMedia may be set.
  1059. func (c *UsersDraftsCreateCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsCreateCall {
  1060. opts := googleapi.ProcessMediaOptions(options)
  1061. chunkSize := opts.ChunkSize
  1062. r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)
  1063. c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)
  1064. return c
  1065. }
  1066. // ResumableMedia specifies the media to upload in chunks and can be
  1067. // canceled with ctx.
  1068. //
  1069. // Deprecated: use Media instead.
  1070. //
  1071. // At most one of Media and ResumableMedia may be set. mediaType
  1072. // identifies the MIME media type of the upload, such as "image/png". If
  1073. // mediaType is "", it will be auto-detected. The provided ctx will
  1074. // supersede any context previously provided to the Context method.
  1075. func (c *UsersDraftsCreateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsCreateCall {
  1076. c.ctx_ = ctx
  1077. rdr := gensupport.ReaderAtToReader(r, size)
  1078. rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)
  1079. c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)
  1080. c.media_ = nil
  1081. c.mediaSize_ = size
  1082. return c
  1083. }
  1084. // ProgressUpdater provides a callback function that will be called
  1085. // after every chunk. It should be a low-latency function in order to
  1086. // not slow down the upload operation. This should only be called when
  1087. // using ResumableMedia (as opposed to Media).
  1088. func (c *UsersDraftsCreateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsCreateCall {
  1089. c.progressUpdater_ = pu
  1090. return c
  1091. }
  1092. // Fields allows partial responses to be retrieved. See
  1093. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1094. // for more information.
  1095. func (c *UsersDraftsCreateCall) Fields(s ...googleapi.Field) *UsersDraftsCreateCall {
  1096. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1097. return c
  1098. }
  1099. // Context sets the context to be used in this call's Do method. Any
  1100. // pending HTTP request will be aborted if the provided context is
  1101. // canceled.
  1102. // This context will supersede any context previously provided to the
  1103. // ResumableMedia method.
  1104. func (c *UsersDraftsCreateCall) Context(ctx context.Context) *UsersDraftsCreateCall {
  1105. c.ctx_ = ctx
  1106. return c
  1107. }
  1108. func (c *UsersDraftsCreateCall) doRequest(alt string) (*http.Response, error) {
  1109. var body io.Reader = nil
  1110. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  1111. if err != nil {
  1112. return nil, err
  1113. }
  1114. ctype := "application/json"
  1115. c.urlParams_.Set("alt", alt)
  1116. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
  1117. if c.media_ != nil || c.resumableBuffer_ != nil {
  1118. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  1119. protocol := "multipart"
  1120. if c.resumableBuffer_ != nil {
  1121. protocol = "resumable"
  1122. }
  1123. c.urlParams_.Set("uploadType", protocol)
  1124. }
  1125. urls += "?" + c.urlParams_.Encode()
  1126. if c.media_ != nil {
  1127. var combined io.ReadCloser
  1128. combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)
  1129. defer combined.Close()
  1130. body = combined
  1131. }
  1132. req, _ := http.NewRequest("POST", urls, body)
  1133. googleapi.Expand(req.URL, map[string]string{
  1134. "userId": c.userId,
  1135. })
  1136. if c.resumableBuffer_ != nil {
  1137. req.Header.Set("X-Upload-Content-Type", c.mediaType_)
  1138. }
  1139. req.Header.Set("Content-Type", ctype)
  1140. req.Header.Set("User-Agent", c.s.userAgent())
  1141. if c.ctx_ != nil {
  1142. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1143. }
  1144. return c.s.client.Do(req)
  1145. }
  1146. // Do executes the "gmail.users.drafts.create" call.
  1147. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  1148. // code is an error. Response headers are in either
  1149. // *Draft.ServerResponse.Header or (if a response was returned at all)
  1150. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1151. // check whether the returned error was because http.StatusNotModified
  1152. // was returned.
  1153. func (c *UsersDraftsCreateCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  1154. gensupport.SetOptions(c.urlParams_, opts...)
  1155. res, err := gensupport.Retry(c.ctx_, func() (*http.Response, error) {
  1156. return c.doRequest("json")
  1157. }, gensupport.DefaultBackoffStrategy())
  1158. if res != nil && res.StatusCode == http.StatusNotModified {
  1159. if res.Body != nil {
  1160. res.Body.Close()
  1161. }
  1162. return nil, &googleapi.Error{
  1163. Code: res.StatusCode,
  1164. Header: res.Header,
  1165. }
  1166. }
  1167. if err != nil {
  1168. return nil, err
  1169. }
  1170. defer googleapi.CloseBody(res)
  1171. if err := googleapi.CheckResponse(res); err != nil {
  1172. return nil, err
  1173. }
  1174. if c.resumableBuffer_ != nil {
  1175. loc := res.Header.Get("Location")
  1176. rx := &gensupport.ResumableUpload{
  1177. Client: c.s.client,
  1178. UserAgent: c.s.userAgent(),
  1179. URI: loc,
  1180. Media: c.resumableBuffer_,
  1181. MediaType: c.mediaType_,
  1182. Callback: func(curr int64) {
  1183. if c.progressUpdater_ != nil {
  1184. c.progressUpdater_(curr, c.mediaSize_)
  1185. }
  1186. },
  1187. }
  1188. ctx := c.ctx_
  1189. if ctx == nil {
  1190. ctx = context.TODO()
  1191. }
  1192. res, err = rx.Upload(ctx)
  1193. if err != nil {
  1194. return nil, err
  1195. }
  1196. defer res.Body.Close()
  1197. if err := googleapi.CheckResponse(res); err != nil {
  1198. return nil, err
  1199. }
  1200. }
  1201. ret := &Draft{
  1202. ServerResponse: googleapi.ServerResponse{
  1203. Header: res.Header,
  1204. HTTPStatusCode: res.StatusCode,
  1205. },
  1206. }
  1207. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1208. return nil, err
  1209. }
  1210. return ret, nil
  1211. // {
  1212. // "description": "Creates a new draft with the DRAFT label.",
  1213. // "httpMethod": "POST",
  1214. // "id": "gmail.users.drafts.create",
  1215. // "mediaUpload": {
  1216. // "accept": [
  1217. // "message/rfc822"
  1218. // ],
  1219. // "maxSize": "35MB",
  1220. // "protocols": {
  1221. // "resumable": {
  1222. // "multipart": true,
  1223. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts"
  1224. // },
  1225. // "simple": {
  1226. // "multipart": true,
  1227. // "path": "/upload/gmail/v1/users/{userId}/drafts"
  1228. // }
  1229. // }
  1230. // },
  1231. // "parameterOrder": [
  1232. // "userId"
  1233. // ],
  1234. // "parameters": {
  1235. // "userId": {
  1236. // "default": "me",
  1237. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1238. // "location": "path",
  1239. // "required": true,
  1240. // "type": "string"
  1241. // }
  1242. // },
  1243. // "path": "{userId}/drafts",
  1244. // "request": {
  1245. // "$ref": "Draft"
  1246. // },
  1247. // "response": {
  1248. // "$ref": "Draft"
  1249. // },
  1250. // "scopes": [
  1251. // "https://mail.google.com/",
  1252. // "https://www.googleapis.com/auth/gmail.compose",
  1253. // "https://www.googleapis.com/auth/gmail.modify"
  1254. // ],
  1255. // "supportsMediaUpload": true
  1256. // }
  1257. }
  1258. // method id "gmail.users.drafts.delete":
  1259. type UsersDraftsDeleteCall struct {
  1260. s *Service
  1261. userId string
  1262. id string
  1263. urlParams_ gensupport.URLParams
  1264. ctx_ context.Context
  1265. }
  1266. // Delete: Immediately and permanently deletes the specified draft. Does
  1267. // not simply trash it.
  1268. func (r *UsersDraftsService) Delete(userId string, id string) *UsersDraftsDeleteCall {
  1269. c := &UsersDraftsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1270. c.userId = userId
  1271. c.id = id
  1272. return c
  1273. }
  1274. // Fields allows partial responses to be retrieved. See
  1275. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1276. // for more information.
  1277. func (c *UsersDraftsDeleteCall) Fields(s ...googleapi.Field) *UsersDraftsDeleteCall {
  1278. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1279. return c
  1280. }
  1281. // Context sets the context to be used in this call's Do method. Any
  1282. // pending HTTP request will be aborted if the provided context is
  1283. // canceled.
  1284. func (c *UsersDraftsDeleteCall) Context(ctx context.Context) *UsersDraftsDeleteCall {
  1285. c.ctx_ = ctx
  1286. return c
  1287. }
  1288. func (c *UsersDraftsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1289. var body io.Reader = nil
  1290. c.urlParams_.Set("alt", alt)
  1291. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  1292. urls += "?" + c.urlParams_.Encode()
  1293. req, _ := http.NewRequest("DELETE", urls, body)
  1294. googleapi.Expand(req.URL, map[string]string{
  1295. "userId": c.userId,
  1296. "id": c.id,
  1297. })
  1298. req.Header.Set("User-Agent", c.s.userAgent())
  1299. if c.ctx_ != nil {
  1300. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1301. }
  1302. return c.s.client.Do(req)
  1303. }
  1304. // Do executes the "gmail.users.drafts.delete" call.
  1305. func (c *UsersDraftsDeleteCall) Do(opts ...googleapi.CallOption) error {
  1306. gensupport.SetOptions(c.urlParams_, opts...)
  1307. res, err := c.doRequest("json")
  1308. if err != nil {
  1309. return err
  1310. }
  1311. defer googleapi.CloseBody(res)
  1312. if err := googleapi.CheckResponse(res); err != nil {
  1313. return err
  1314. }
  1315. return nil
  1316. // {
  1317. // "description": "Immediately and permanently deletes the specified draft. Does not simply trash it.",
  1318. // "httpMethod": "DELETE",
  1319. // "id": "gmail.users.drafts.delete",
  1320. // "parameterOrder": [
  1321. // "userId",
  1322. // "id"
  1323. // ],
  1324. // "parameters": {
  1325. // "id": {
  1326. // "description": "The ID of the draft to delete.",
  1327. // "location": "path",
  1328. // "required": true,
  1329. // "type": "string"
  1330. // },
  1331. // "userId": {
  1332. // "default": "me",
  1333. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1334. // "location": "path",
  1335. // "required": true,
  1336. // "type": "string"
  1337. // }
  1338. // },
  1339. // "path": "{userId}/drafts/{id}",
  1340. // "scopes": [
  1341. // "https://mail.google.com/",
  1342. // "https://www.googleapis.com/auth/gmail.compose",
  1343. // "https://www.googleapis.com/auth/gmail.modify"
  1344. // ]
  1345. // }
  1346. }
  1347. // method id "gmail.users.drafts.get":
  1348. type UsersDraftsGetCall struct {
  1349. s *Service
  1350. userId string
  1351. id string
  1352. urlParams_ gensupport.URLParams
  1353. ifNoneMatch_ string
  1354. ctx_ context.Context
  1355. }
  1356. // Get: Gets the specified draft.
  1357. func (r *UsersDraftsService) Get(userId string, id string) *UsersDraftsGetCall {
  1358. c := &UsersDraftsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1359. c.userId = userId
  1360. c.id = id
  1361. return c
  1362. }
  1363. // Format sets the optional parameter "format": The format to return the
  1364. // draft in.
  1365. //
  1366. // Possible values:
  1367. // "full" (default)
  1368. // "metadata"
  1369. // "minimal"
  1370. // "raw"
  1371. func (c *UsersDraftsGetCall) Format(format string) *UsersDraftsGetCall {
  1372. c.urlParams_.Set("format", format)
  1373. return c
  1374. }
  1375. // Fields allows partial responses to be retrieved. See
  1376. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1377. // for more information.
  1378. func (c *UsersDraftsGetCall) Fields(s ...googleapi.Field) *UsersDraftsGetCall {
  1379. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1380. return c
  1381. }
  1382. // IfNoneMatch sets the optional parameter which makes the operation
  1383. // fail if the object's ETag matches the given value. This is useful for
  1384. // getting updates only after the object has changed since the last
  1385. // request. Use googleapi.IsNotModified to check whether the response
  1386. // error from Do is the result of In-None-Match.
  1387. func (c *UsersDraftsGetCall) IfNoneMatch(entityTag string) *UsersDraftsGetCall {
  1388. c.ifNoneMatch_ = entityTag
  1389. return c
  1390. }
  1391. // Context sets the context to be used in this call's Do method. Any
  1392. // pending HTTP request will be aborted if the provided context is
  1393. // canceled.
  1394. func (c *UsersDraftsGetCall) Context(ctx context.Context) *UsersDraftsGetCall {
  1395. c.ctx_ = ctx
  1396. return c
  1397. }
  1398. func (c *UsersDraftsGetCall) doRequest(alt string) (*http.Response, error) {
  1399. var body io.Reader = nil
  1400. c.urlParams_.Set("alt", alt)
  1401. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  1402. urls += "?" + c.urlParams_.Encode()
  1403. req, _ := http.NewRequest("GET", urls, body)
  1404. googleapi.Expand(req.URL, map[string]string{
  1405. "userId": c.userId,
  1406. "id": c.id,
  1407. })
  1408. req.Header.Set("User-Agent", c.s.userAgent())
  1409. if c.ifNoneMatch_ != "" {
  1410. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1411. }
  1412. if c.ctx_ != nil {
  1413. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1414. }
  1415. return c.s.client.Do(req)
  1416. }
  1417. // Do executes the "gmail.users.drafts.get" call.
  1418. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  1419. // code is an error. Response headers are in either
  1420. // *Draft.ServerResponse.Header or (if a response was returned at all)
  1421. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1422. // check whether the returned error was because http.StatusNotModified
  1423. // was returned.
  1424. func (c *UsersDraftsGetCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  1425. gensupport.SetOptions(c.urlParams_, opts...)
  1426. res, err := c.doRequest("json")
  1427. if res != nil && res.StatusCode == http.StatusNotModified {
  1428. if res.Body != nil {
  1429. res.Body.Close()
  1430. }
  1431. return nil, &googleapi.Error{
  1432. Code: res.StatusCode,
  1433. Header: res.Header,
  1434. }
  1435. }
  1436. if err != nil {
  1437. return nil, err
  1438. }
  1439. defer googleapi.CloseBody(res)
  1440. if err := googleapi.CheckResponse(res); err != nil {
  1441. return nil, err
  1442. }
  1443. ret := &Draft{
  1444. ServerResponse: googleapi.ServerResponse{
  1445. Header: res.Header,
  1446. HTTPStatusCode: res.StatusCode,
  1447. },
  1448. }
  1449. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1450. return nil, err
  1451. }
  1452. return ret, nil
  1453. // {
  1454. // "description": "Gets the specified draft.",
  1455. // "httpMethod": "GET",
  1456. // "id": "gmail.users.drafts.get",
  1457. // "parameterOrder": [
  1458. // "userId",
  1459. // "id"
  1460. // ],
  1461. // "parameters": {
  1462. // "format": {
  1463. // "default": "full",
  1464. // "description": "The format to return the draft in.",
  1465. // "enum": [
  1466. // "full",
  1467. // "metadata",
  1468. // "minimal",
  1469. // "raw"
  1470. // ],
  1471. // "enumDescriptions": [
  1472. // "",
  1473. // "",
  1474. // "",
  1475. // ""
  1476. // ],
  1477. // "location": "query",
  1478. // "type": "string"
  1479. // },
  1480. // "id": {
  1481. // "description": "The ID of the draft to retrieve.",
  1482. // "location": "path",
  1483. // "required": true,
  1484. // "type": "string"
  1485. // },
  1486. // "userId": {
  1487. // "default": "me",
  1488. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1489. // "location": "path",
  1490. // "required": true,
  1491. // "type": "string"
  1492. // }
  1493. // },
  1494. // "path": "{userId}/drafts/{id}",
  1495. // "response": {
  1496. // "$ref": "Draft"
  1497. // },
  1498. // "scopes": [
  1499. // "https://mail.google.com/",
  1500. // "https://www.googleapis.com/auth/gmail.compose",
  1501. // "https://www.googleapis.com/auth/gmail.modify",
  1502. // "https://www.googleapis.com/auth/gmail.readonly"
  1503. // ]
  1504. // }
  1505. }
  1506. // method id "gmail.users.drafts.list":
  1507. type UsersDraftsListCall struct {
  1508. s *Service
  1509. userId string
  1510. urlParams_ gensupport.URLParams
  1511. ifNoneMatch_ string
  1512. ctx_ context.Context
  1513. }
  1514. // List: Lists the drafts in the user's mailbox.
  1515. func (r *UsersDraftsService) List(userId string) *UsersDraftsListCall {
  1516. c := &UsersDraftsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1517. c.userId = userId
  1518. return c
  1519. }
  1520. // MaxResults sets the optional parameter "maxResults": Maximum number
  1521. // of drafts to return.
  1522. func (c *UsersDraftsListCall) MaxResults(maxResults int64) *UsersDraftsListCall {
  1523. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1524. return c
  1525. }
  1526. // PageToken sets the optional parameter "pageToken": Page token to
  1527. // retrieve a specific page of results in the list.
  1528. func (c *UsersDraftsListCall) PageToken(pageToken string) *UsersDraftsListCall {
  1529. c.urlParams_.Set("pageToken", pageToken)
  1530. return c
  1531. }
  1532. // Fields allows partial responses to be retrieved. See
  1533. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1534. // for more information.
  1535. func (c *UsersDraftsListCall) Fields(s ...googleapi.Field) *UsersDraftsListCall {
  1536. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1537. return c
  1538. }
  1539. // IfNoneMatch sets the optional parameter which makes the operation
  1540. // fail if the object's ETag matches the given value. This is useful for
  1541. // getting updates only after the object has changed since the last
  1542. // request. Use googleapi.IsNotModified to check whether the response
  1543. // error from Do is the result of In-None-Match.
  1544. func (c *UsersDraftsListCall) IfNoneMatch(entityTag string) *UsersDraftsListCall {
  1545. c.ifNoneMatch_ = entityTag
  1546. return c
  1547. }
  1548. // Context sets the context to be used in this call's Do method. Any
  1549. // pending HTTP request will be aborted if the provided context is
  1550. // canceled.
  1551. func (c *UsersDraftsListCall) Context(ctx context.Context) *UsersDraftsListCall {
  1552. c.ctx_ = ctx
  1553. return c
  1554. }
  1555. func (c *UsersDraftsListCall) doRequest(alt string) (*http.Response, error) {
  1556. var body io.Reader = nil
  1557. c.urlParams_.Set("alt", alt)
  1558. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts")
  1559. urls += "?" + c.urlParams_.Encode()
  1560. req, _ := http.NewRequest("GET", urls, body)
  1561. googleapi.Expand(req.URL, map[string]string{
  1562. "userId": c.userId,
  1563. })
  1564. req.Header.Set("User-Agent", c.s.userAgent())
  1565. if c.ifNoneMatch_ != "" {
  1566. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1567. }
  1568. if c.ctx_ != nil {
  1569. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1570. }
  1571. return c.s.client.Do(req)
  1572. }
  1573. // Do executes the "gmail.users.drafts.list" call.
  1574. // Exactly one of *ListDraftsResponse or error will be non-nil. Any
  1575. // non-2xx status code is an error. Response headers are in either
  1576. // *ListDraftsResponse.ServerResponse.Header or (if a response was
  1577. // returned at all) in error.(*googleapi.Error).Header. Use
  1578. // googleapi.IsNotModified to check whether the returned error was
  1579. // because http.StatusNotModified was returned.
  1580. func (c *UsersDraftsListCall) Do(opts ...googleapi.CallOption) (*ListDraftsResponse, error) {
  1581. gensupport.SetOptions(c.urlParams_, opts...)
  1582. res, err := c.doRequest("json")
  1583. if res != nil && res.StatusCode == http.StatusNotModified {
  1584. if res.Body != nil {
  1585. res.Body.Close()
  1586. }
  1587. return nil, &googleapi.Error{
  1588. Code: res.StatusCode,
  1589. Header: res.Header,
  1590. }
  1591. }
  1592. if err != nil {
  1593. return nil, err
  1594. }
  1595. defer googleapi.CloseBody(res)
  1596. if err := googleapi.CheckResponse(res); err != nil {
  1597. return nil, err
  1598. }
  1599. ret := &ListDraftsResponse{
  1600. ServerResponse: googleapi.ServerResponse{
  1601. Header: res.Header,
  1602. HTTPStatusCode: res.StatusCode,
  1603. },
  1604. }
  1605. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1606. return nil, err
  1607. }
  1608. return ret, nil
  1609. // {
  1610. // "description": "Lists the drafts in the user's mailbox.",
  1611. // "httpMethod": "GET",
  1612. // "id": "gmail.users.drafts.list",
  1613. // "parameterOrder": [
  1614. // "userId"
  1615. // ],
  1616. // "parameters": {
  1617. // "maxResults": {
  1618. // "default": "100",
  1619. // "description": "Maximum number of drafts to return.",
  1620. // "format": "uint32",
  1621. // "location": "query",
  1622. // "type": "integer"
  1623. // },
  1624. // "pageToken": {
  1625. // "description": "Page token to retrieve a specific page of results in the list.",
  1626. // "location": "query",
  1627. // "type": "string"
  1628. // },
  1629. // "userId": {
  1630. // "default": "me",
  1631. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1632. // "location": "path",
  1633. // "required": true,
  1634. // "type": "string"
  1635. // }
  1636. // },
  1637. // "path": "{userId}/drafts",
  1638. // "response": {
  1639. // "$ref": "ListDraftsResponse"
  1640. // },
  1641. // "scopes": [
  1642. // "https://mail.google.com/",
  1643. // "https://www.googleapis.com/auth/gmail.compose",
  1644. // "https://www.googleapis.com/auth/gmail.modify",
  1645. // "https://www.googleapis.com/auth/gmail.readonly"
  1646. // ]
  1647. // }
  1648. }
  1649. // Pages invokes f for each page of results.
  1650. // A non-nil error returned from f will halt the iteration.
  1651. // The provided context supersedes any context provided to the Context method.
  1652. func (c *UsersDraftsListCall) Pages(ctx context.Context, f func(*ListDraftsResponse) error) error {
  1653. c.ctx_ = ctx
  1654. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1655. for {
  1656. x, err := c.Do()
  1657. if err != nil {
  1658. return err
  1659. }
  1660. if err := f(x); err != nil {
  1661. return err
  1662. }
  1663. if x.NextPageToken == "" {
  1664. return nil
  1665. }
  1666. c.PageToken(x.NextPageToken)
  1667. }
  1668. }
  1669. // method id "gmail.users.drafts.send":
  1670. type UsersDraftsSendCall struct {
  1671. s *Service
  1672. userId string
  1673. draft *Draft
  1674. urlParams_ gensupport.URLParams
  1675. media_ io.Reader
  1676. resumableBuffer_ *gensupport.ResumableBuffer
  1677. mediaType_ string
  1678. mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_.
  1679. progressUpdater_ googleapi.ProgressUpdater
  1680. ctx_ context.Context
  1681. }
  1682. // Send: Sends the specified, existing draft to the recipients in the
  1683. // To, Cc, and Bcc headers.
  1684. func (r *UsersDraftsService) Send(userId string, draft *Draft) *UsersDraftsSendCall {
  1685. c := &UsersDraftsSendCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1686. c.userId = userId
  1687. c.draft = draft
  1688. return c
  1689. }
  1690. // Media specifies the media to upload in one or more chunks. The chunk
  1691. // size may be controlled by supplying a MediaOption generated by
  1692. // googleapi.ChunkSize. The chunk size defaults to
  1693. // googleapi.DefaultUploadChunkSize.
  1694. // At most one of Media and ResumableMedia may be set.
  1695. func (c *UsersDraftsSendCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsSendCall {
  1696. opts := googleapi.ProcessMediaOptions(options)
  1697. chunkSize := opts.ChunkSize
  1698. r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)
  1699. c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)
  1700. return c
  1701. }
  1702. // ResumableMedia specifies the media to upload in chunks and can be
  1703. // canceled with ctx.
  1704. //
  1705. // Deprecated: use Media instead.
  1706. //
  1707. // At most one of Media and ResumableMedia may be set. mediaType
  1708. // identifies the MIME media type of the upload, such as "image/png". If
  1709. // mediaType is "", it will be auto-detected. The provided ctx will
  1710. // supersede any context previously provided to the Context method.
  1711. func (c *UsersDraftsSendCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsSendCall {
  1712. c.ctx_ = ctx
  1713. rdr := gensupport.ReaderAtToReader(r, size)
  1714. rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)
  1715. c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)
  1716. c.media_ = nil
  1717. c.mediaSize_ = size
  1718. return c
  1719. }
  1720. // ProgressUpdater provides a callback function that will be called
  1721. // after every chunk. It should be a low-latency function in order to
  1722. // not slow down the upload operation. This should only be called when
  1723. // using ResumableMedia (as opposed to Media).
  1724. func (c *UsersDraftsSendCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsSendCall {
  1725. c.progressUpdater_ = pu
  1726. return c
  1727. }
  1728. // Fields allows partial responses to be retrieved. See
  1729. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1730. // for more information.
  1731. func (c *UsersDraftsSendCall) Fields(s ...googleapi.Field) *UsersDraftsSendCall {
  1732. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1733. return c
  1734. }
  1735. // Context sets the context to be used in this call's Do method. Any
  1736. // pending HTTP request will be aborted if the provided context is
  1737. // canceled.
  1738. // This context will supersede any context previously provided to the
  1739. // ResumableMedia method.
  1740. func (c *UsersDraftsSendCall) Context(ctx context.Context) *UsersDraftsSendCall {
  1741. c.ctx_ = ctx
  1742. return c
  1743. }
  1744. func (c *UsersDraftsSendCall) doRequest(alt string) (*http.Response, error) {
  1745. var body io.Reader = nil
  1746. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  1747. if err != nil {
  1748. return nil, err
  1749. }
  1750. ctype := "application/json"
  1751. c.urlParams_.Set("alt", alt)
  1752. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/send")
  1753. if c.media_ != nil || c.resumableBuffer_ != nil {
  1754. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  1755. protocol := "multipart"
  1756. if c.resumableBuffer_ != nil {
  1757. protocol = "resumable"
  1758. }
  1759. c.urlParams_.Set("uploadType", protocol)
  1760. }
  1761. urls += "?" + c.urlParams_.Encode()
  1762. if c.media_ != nil {
  1763. var combined io.ReadCloser
  1764. combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)
  1765. defer combined.Close()
  1766. body = combined
  1767. }
  1768. req, _ := http.NewRequest("POST", urls, body)
  1769. googleapi.Expand(req.URL, map[string]string{
  1770. "userId": c.userId,
  1771. })
  1772. if c.resumableBuffer_ != nil {
  1773. req.Header.Set("X-Upload-Content-Type", c.mediaType_)
  1774. }
  1775. req.Header.Set("Content-Type", ctype)
  1776. req.Header.Set("User-Agent", c.s.userAgent())
  1777. if c.ctx_ != nil {
  1778. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1779. }
  1780. return c.s.client.Do(req)
  1781. }
  1782. // Do executes the "gmail.users.drafts.send" call.
  1783. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  1784. // code is an error. Response headers are in either
  1785. // *Message.ServerResponse.Header or (if a response was returned at all)
  1786. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1787. // check whether the returned error was because http.StatusNotModified
  1788. // was returned.
  1789. func (c *UsersDraftsSendCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  1790. gensupport.SetOptions(c.urlParams_, opts...)
  1791. res, err := gensupport.Retry(c.ctx_, func() (*http.Response, error) {
  1792. return c.doRequest("json")
  1793. }, gensupport.DefaultBackoffStrategy())
  1794. if res != nil && res.StatusCode == http.StatusNotModified {
  1795. if res.Body != nil {
  1796. res.Body.Close()
  1797. }
  1798. return nil, &googleapi.Error{
  1799. Code: res.StatusCode,
  1800. Header: res.Header,
  1801. }
  1802. }
  1803. if err != nil {
  1804. return nil, err
  1805. }
  1806. defer googleapi.CloseBody(res)
  1807. if err := googleapi.CheckResponse(res); err != nil {
  1808. return nil, err
  1809. }
  1810. if c.resumableBuffer_ != nil {
  1811. loc := res.Header.Get("Location")
  1812. rx := &gensupport.ResumableUpload{
  1813. Client: c.s.client,
  1814. UserAgent: c.s.userAgent(),
  1815. URI: loc,
  1816. Media: c.resumableBuffer_,
  1817. MediaType: c.mediaType_,
  1818. Callback: func(curr int64) {
  1819. if c.progressUpdater_ != nil {
  1820. c.progressUpdater_(curr, c.mediaSize_)
  1821. }
  1822. },
  1823. }
  1824. ctx := c.ctx_
  1825. if ctx == nil {
  1826. ctx = context.TODO()
  1827. }
  1828. res, err = rx.Upload(ctx)
  1829. if err != nil {
  1830. return nil, err
  1831. }
  1832. defer res.Body.Close()
  1833. if err := googleapi.CheckResponse(res); err != nil {
  1834. return nil, err
  1835. }
  1836. }
  1837. ret := &Message{
  1838. ServerResponse: googleapi.ServerResponse{
  1839. Header: res.Header,
  1840. HTTPStatusCode: res.StatusCode,
  1841. },
  1842. }
  1843. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1844. return nil, err
  1845. }
  1846. return ret, nil
  1847. // {
  1848. // "description": "Sends the specified, existing draft to the recipients in the To, Cc, and Bcc headers.",
  1849. // "httpMethod": "POST",
  1850. // "id": "gmail.users.drafts.send",
  1851. // "mediaUpload": {
  1852. // "accept": [
  1853. // "message/rfc822"
  1854. // ],
  1855. // "maxSize": "35MB",
  1856. // "protocols": {
  1857. // "resumable": {
  1858. // "multipart": true,
  1859. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/send"
  1860. // },
  1861. // "simple": {
  1862. // "multipart": true,
  1863. // "path": "/upload/gmail/v1/users/{userId}/drafts/send"
  1864. // }
  1865. // }
  1866. // },
  1867. // "parameterOrder": [
  1868. // "userId"
  1869. // ],
  1870. // "parameters": {
  1871. // "userId": {
  1872. // "default": "me",
  1873. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  1874. // "location": "path",
  1875. // "required": true,
  1876. // "type": "string"
  1877. // }
  1878. // },
  1879. // "path": "{userId}/drafts/send",
  1880. // "request": {
  1881. // "$ref": "Draft"
  1882. // },
  1883. // "response": {
  1884. // "$ref": "Message"
  1885. // },
  1886. // "scopes": [
  1887. // "https://mail.google.com/",
  1888. // "https://www.googleapis.com/auth/gmail.compose",
  1889. // "https://www.googleapis.com/auth/gmail.modify"
  1890. // ],
  1891. // "supportsMediaUpload": true
  1892. // }
  1893. }
  1894. // method id "gmail.users.drafts.update":
  1895. type UsersDraftsUpdateCall struct {
  1896. s *Service
  1897. userId string
  1898. id string
  1899. draft *Draft
  1900. urlParams_ gensupport.URLParams
  1901. media_ io.Reader
  1902. resumableBuffer_ *gensupport.ResumableBuffer
  1903. mediaType_ string
  1904. mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_.
  1905. progressUpdater_ googleapi.ProgressUpdater
  1906. ctx_ context.Context
  1907. }
  1908. // Update: Replaces a draft's content.
  1909. func (r *UsersDraftsService) Update(userId string, id string, draft *Draft) *UsersDraftsUpdateCall {
  1910. c := &UsersDraftsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1911. c.userId = userId
  1912. c.id = id
  1913. c.draft = draft
  1914. return c
  1915. }
  1916. // Media specifies the media to upload in one or more chunks. The chunk
  1917. // size may be controlled by supplying a MediaOption generated by
  1918. // googleapi.ChunkSize. The chunk size defaults to
  1919. // googleapi.DefaultUploadChunkSize.
  1920. // At most one of Media and ResumableMedia may be set.
  1921. func (c *UsersDraftsUpdateCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersDraftsUpdateCall {
  1922. opts := googleapi.ProcessMediaOptions(options)
  1923. chunkSize := opts.ChunkSize
  1924. r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)
  1925. c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)
  1926. return c
  1927. }
  1928. // ResumableMedia specifies the media to upload in chunks and can be
  1929. // canceled with ctx.
  1930. //
  1931. // Deprecated: use Media instead.
  1932. //
  1933. // At most one of Media and ResumableMedia may be set. mediaType
  1934. // identifies the MIME media type of the upload, such as "image/png". If
  1935. // mediaType is "", it will be auto-detected. The provided ctx will
  1936. // supersede any context previously provided to the Context method.
  1937. func (c *UsersDraftsUpdateCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersDraftsUpdateCall {
  1938. c.ctx_ = ctx
  1939. rdr := gensupport.ReaderAtToReader(r, size)
  1940. rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)
  1941. c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)
  1942. c.media_ = nil
  1943. c.mediaSize_ = size
  1944. return c
  1945. }
  1946. // ProgressUpdater provides a callback function that will be called
  1947. // after every chunk. It should be a low-latency function in order to
  1948. // not slow down the upload operation. This should only be called when
  1949. // using ResumableMedia (as opposed to Media).
  1950. func (c *UsersDraftsUpdateCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersDraftsUpdateCall {
  1951. c.progressUpdater_ = pu
  1952. return c
  1953. }
  1954. // Fields allows partial responses to be retrieved. See
  1955. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1956. // for more information.
  1957. func (c *UsersDraftsUpdateCall) Fields(s ...googleapi.Field) *UsersDraftsUpdateCall {
  1958. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1959. return c
  1960. }
  1961. // Context sets the context to be used in this call's Do method. Any
  1962. // pending HTTP request will be aborted if the provided context is
  1963. // canceled.
  1964. // This context will supersede any context previously provided to the
  1965. // ResumableMedia method.
  1966. func (c *UsersDraftsUpdateCall) Context(ctx context.Context) *UsersDraftsUpdateCall {
  1967. c.ctx_ = ctx
  1968. return c
  1969. }
  1970. func (c *UsersDraftsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1971. var body io.Reader = nil
  1972. body, err := googleapi.WithoutDataWrapper.JSONReader(c.draft)
  1973. if err != nil {
  1974. return nil, err
  1975. }
  1976. ctype := "application/json"
  1977. c.urlParams_.Set("alt", alt)
  1978. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/drafts/{id}")
  1979. if c.media_ != nil || c.resumableBuffer_ != nil {
  1980. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  1981. protocol := "multipart"
  1982. if c.resumableBuffer_ != nil {
  1983. protocol = "resumable"
  1984. }
  1985. c.urlParams_.Set("uploadType", protocol)
  1986. }
  1987. urls += "?" + c.urlParams_.Encode()
  1988. if c.media_ != nil {
  1989. var combined io.ReadCloser
  1990. combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)
  1991. defer combined.Close()
  1992. body = combined
  1993. }
  1994. req, _ := http.NewRequest("PUT", urls, body)
  1995. googleapi.Expand(req.URL, map[string]string{
  1996. "userId": c.userId,
  1997. "id": c.id,
  1998. })
  1999. if c.resumableBuffer_ != nil {
  2000. req.Header.Set("X-Upload-Content-Type", c.mediaType_)
  2001. }
  2002. req.Header.Set("Content-Type", ctype)
  2003. req.Header.Set("User-Agent", c.s.userAgent())
  2004. if c.ctx_ != nil {
  2005. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2006. }
  2007. return c.s.client.Do(req)
  2008. }
  2009. // Do executes the "gmail.users.drafts.update" call.
  2010. // Exactly one of *Draft or error will be non-nil. Any non-2xx status
  2011. // code is an error. Response headers are in either
  2012. // *Draft.ServerResponse.Header or (if a response was returned at all)
  2013. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2014. // check whether the returned error was because http.StatusNotModified
  2015. // was returned.
  2016. func (c *UsersDraftsUpdateCall) Do(opts ...googleapi.CallOption) (*Draft, error) {
  2017. gensupport.SetOptions(c.urlParams_, opts...)
  2018. res, err := gensupport.Retry(c.ctx_, func() (*http.Response, error) {
  2019. return c.doRequest("json")
  2020. }, gensupport.DefaultBackoffStrategy())
  2021. if res != nil && res.StatusCode == http.StatusNotModified {
  2022. if res.Body != nil {
  2023. res.Body.Close()
  2024. }
  2025. return nil, &googleapi.Error{
  2026. Code: res.StatusCode,
  2027. Header: res.Header,
  2028. }
  2029. }
  2030. if err != nil {
  2031. return nil, err
  2032. }
  2033. defer googleapi.CloseBody(res)
  2034. if err := googleapi.CheckResponse(res); err != nil {
  2035. return nil, err
  2036. }
  2037. if c.resumableBuffer_ != nil {
  2038. loc := res.Header.Get("Location")
  2039. rx := &gensupport.ResumableUpload{
  2040. Client: c.s.client,
  2041. UserAgent: c.s.userAgent(),
  2042. URI: loc,
  2043. Media: c.resumableBuffer_,
  2044. MediaType: c.mediaType_,
  2045. Callback: func(curr int64) {
  2046. if c.progressUpdater_ != nil {
  2047. c.progressUpdater_(curr, c.mediaSize_)
  2048. }
  2049. },
  2050. }
  2051. ctx := c.ctx_
  2052. if ctx == nil {
  2053. ctx = context.TODO()
  2054. }
  2055. res, err = rx.Upload(ctx)
  2056. if err != nil {
  2057. return nil, err
  2058. }
  2059. defer res.Body.Close()
  2060. if err := googleapi.CheckResponse(res); err != nil {
  2061. return nil, err
  2062. }
  2063. }
  2064. ret := &Draft{
  2065. ServerResponse: googleapi.ServerResponse{
  2066. Header: res.Header,
  2067. HTTPStatusCode: res.StatusCode,
  2068. },
  2069. }
  2070. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2071. return nil, err
  2072. }
  2073. return ret, nil
  2074. // {
  2075. // "description": "Replaces a draft's content.",
  2076. // "httpMethod": "PUT",
  2077. // "id": "gmail.users.drafts.update",
  2078. // "mediaUpload": {
  2079. // "accept": [
  2080. // "message/rfc822"
  2081. // ],
  2082. // "maxSize": "35MB",
  2083. // "protocols": {
  2084. // "resumable": {
  2085. // "multipart": true,
  2086. // "path": "/resumable/upload/gmail/v1/users/{userId}/drafts/{id}"
  2087. // },
  2088. // "simple": {
  2089. // "multipart": true,
  2090. // "path": "/upload/gmail/v1/users/{userId}/drafts/{id}"
  2091. // }
  2092. // }
  2093. // },
  2094. // "parameterOrder": [
  2095. // "userId",
  2096. // "id"
  2097. // ],
  2098. // "parameters": {
  2099. // "id": {
  2100. // "description": "The ID of the draft to update.",
  2101. // "location": "path",
  2102. // "required": true,
  2103. // "type": "string"
  2104. // },
  2105. // "userId": {
  2106. // "default": "me",
  2107. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2108. // "location": "path",
  2109. // "required": true,
  2110. // "type": "string"
  2111. // }
  2112. // },
  2113. // "path": "{userId}/drafts/{id}",
  2114. // "request": {
  2115. // "$ref": "Draft"
  2116. // },
  2117. // "response": {
  2118. // "$ref": "Draft"
  2119. // },
  2120. // "scopes": [
  2121. // "https://mail.google.com/",
  2122. // "https://www.googleapis.com/auth/gmail.compose",
  2123. // "https://www.googleapis.com/auth/gmail.modify"
  2124. // ],
  2125. // "supportsMediaUpload": true
  2126. // }
  2127. }
  2128. // method id "gmail.users.history.list":
  2129. type UsersHistoryListCall struct {
  2130. s *Service
  2131. userId string
  2132. urlParams_ gensupport.URLParams
  2133. ifNoneMatch_ string
  2134. ctx_ context.Context
  2135. }
  2136. // List: Lists the history of all changes to the given mailbox. History
  2137. // results are returned in chronological order (increasing historyId).
  2138. func (r *UsersHistoryService) List(userId string) *UsersHistoryListCall {
  2139. c := &UsersHistoryListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2140. c.userId = userId
  2141. return c
  2142. }
  2143. // LabelId sets the optional parameter "labelId": Only return messages
  2144. // with a label matching the ID.
  2145. func (c *UsersHistoryListCall) LabelId(labelId string) *UsersHistoryListCall {
  2146. c.urlParams_.Set("labelId", labelId)
  2147. return c
  2148. }
  2149. // MaxResults sets the optional parameter "maxResults": The maximum
  2150. // number of history records to return.
  2151. func (c *UsersHistoryListCall) MaxResults(maxResults int64) *UsersHistoryListCall {
  2152. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  2153. return c
  2154. }
  2155. // PageToken sets the optional parameter "pageToken": Page token to
  2156. // retrieve a specific page of results in the list.
  2157. func (c *UsersHistoryListCall) PageToken(pageToken string) *UsersHistoryListCall {
  2158. c.urlParams_.Set("pageToken", pageToken)
  2159. return c
  2160. }
  2161. // StartHistoryId sets the optional parameter "startHistoryId":
  2162. // Required. Returns history records after the specified startHistoryId.
  2163. // The supplied startHistoryId should be obtained from the historyId of
  2164. // a message, thread, or previous list response. History IDs increase
  2165. // chronologically but are not contiguous with random gaps in between
  2166. // valid IDs. Supplying an invalid or out of date startHistoryId
  2167. // typically returns an HTTP 404 error code. A historyId is typically
  2168. // valid for at least a week, but in some rare circumstances may be
  2169. // valid for only a few hours. If you receive an HTTP 404 error
  2170. // response, your application should perform a full sync. If you receive
  2171. // no nextPageToken in the response, there are no updates to retrieve
  2172. // and you can store the returned historyId for a future request.
  2173. func (c *UsersHistoryListCall) StartHistoryId(startHistoryId uint64) *UsersHistoryListCall {
  2174. c.urlParams_.Set("startHistoryId", fmt.Sprint(startHistoryId))
  2175. return c
  2176. }
  2177. // Fields allows partial responses to be retrieved. See
  2178. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2179. // for more information.
  2180. func (c *UsersHistoryListCall) Fields(s ...googleapi.Field) *UsersHistoryListCall {
  2181. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2182. return c
  2183. }
  2184. // IfNoneMatch sets the optional parameter which makes the operation
  2185. // fail if the object's ETag matches the given value. This is useful for
  2186. // getting updates only after the object has changed since the last
  2187. // request. Use googleapi.IsNotModified to check whether the response
  2188. // error from Do is the result of In-None-Match.
  2189. func (c *UsersHistoryListCall) IfNoneMatch(entityTag string) *UsersHistoryListCall {
  2190. c.ifNoneMatch_ = entityTag
  2191. return c
  2192. }
  2193. // Context sets the context to be used in this call's Do method. Any
  2194. // pending HTTP request will be aborted if the provided context is
  2195. // canceled.
  2196. func (c *UsersHistoryListCall) Context(ctx context.Context) *UsersHistoryListCall {
  2197. c.ctx_ = ctx
  2198. return c
  2199. }
  2200. func (c *UsersHistoryListCall) doRequest(alt string) (*http.Response, error) {
  2201. var body io.Reader = nil
  2202. c.urlParams_.Set("alt", alt)
  2203. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/history")
  2204. urls += "?" + c.urlParams_.Encode()
  2205. req, _ := http.NewRequest("GET", urls, body)
  2206. googleapi.Expand(req.URL, map[string]string{
  2207. "userId": c.userId,
  2208. })
  2209. req.Header.Set("User-Agent", c.s.userAgent())
  2210. if c.ifNoneMatch_ != "" {
  2211. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2212. }
  2213. if c.ctx_ != nil {
  2214. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2215. }
  2216. return c.s.client.Do(req)
  2217. }
  2218. // Do executes the "gmail.users.history.list" call.
  2219. // Exactly one of *ListHistoryResponse or error will be non-nil. Any
  2220. // non-2xx status code is an error. Response headers are in either
  2221. // *ListHistoryResponse.ServerResponse.Header or (if a response was
  2222. // returned at all) in error.(*googleapi.Error).Header. Use
  2223. // googleapi.IsNotModified to check whether the returned error was
  2224. // because http.StatusNotModified was returned.
  2225. func (c *UsersHistoryListCall) Do(opts ...googleapi.CallOption) (*ListHistoryResponse, error) {
  2226. gensupport.SetOptions(c.urlParams_, opts...)
  2227. res, err := c.doRequest("json")
  2228. if res != nil && res.StatusCode == http.StatusNotModified {
  2229. if res.Body != nil {
  2230. res.Body.Close()
  2231. }
  2232. return nil, &googleapi.Error{
  2233. Code: res.StatusCode,
  2234. Header: res.Header,
  2235. }
  2236. }
  2237. if err != nil {
  2238. return nil, err
  2239. }
  2240. defer googleapi.CloseBody(res)
  2241. if err := googleapi.CheckResponse(res); err != nil {
  2242. return nil, err
  2243. }
  2244. ret := &ListHistoryResponse{
  2245. ServerResponse: googleapi.ServerResponse{
  2246. Header: res.Header,
  2247. HTTPStatusCode: res.StatusCode,
  2248. },
  2249. }
  2250. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2251. return nil, err
  2252. }
  2253. return ret, nil
  2254. // {
  2255. // "description": "Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing historyId).",
  2256. // "httpMethod": "GET",
  2257. // "id": "gmail.users.history.list",
  2258. // "parameterOrder": [
  2259. // "userId"
  2260. // ],
  2261. // "parameters": {
  2262. // "labelId": {
  2263. // "description": "Only return messages with a label matching the ID.",
  2264. // "location": "query",
  2265. // "type": "string"
  2266. // },
  2267. // "maxResults": {
  2268. // "default": "100",
  2269. // "description": "The maximum number of history records to return.",
  2270. // "format": "uint32",
  2271. // "location": "query",
  2272. // "type": "integer"
  2273. // },
  2274. // "pageToken": {
  2275. // "description": "Page token to retrieve a specific page of results in the list.",
  2276. // "location": "query",
  2277. // "type": "string"
  2278. // },
  2279. // "startHistoryId": {
  2280. // "description": "Required. Returns history records after the specified startHistoryId. The supplied startHistoryId should be obtained from the historyId of a message, thread, or previous list response. History IDs increase chronologically but are not contiguous with random gaps in between valid IDs. Supplying an invalid or out of date startHistoryId typically returns an HTTP 404 error code. A historyId is typically valid for at least a week, but in some rare circumstances may be valid for only a few hours. If you receive an HTTP 404 error response, your application should perform a full sync. If you receive no nextPageToken in the response, there are no updates to retrieve and you can store the returned historyId for a future request.",
  2281. // "format": "uint64",
  2282. // "location": "query",
  2283. // "type": "string"
  2284. // },
  2285. // "userId": {
  2286. // "default": "me",
  2287. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2288. // "location": "path",
  2289. // "required": true,
  2290. // "type": "string"
  2291. // }
  2292. // },
  2293. // "path": "{userId}/history",
  2294. // "response": {
  2295. // "$ref": "ListHistoryResponse"
  2296. // },
  2297. // "scopes": [
  2298. // "https://mail.google.com/",
  2299. // "https://www.googleapis.com/auth/gmail.modify",
  2300. // "https://www.googleapis.com/auth/gmail.readonly"
  2301. // ]
  2302. // }
  2303. }
  2304. // Pages invokes f for each page of results.
  2305. // A non-nil error returned from f will halt the iteration.
  2306. // The provided context supersedes any context provided to the Context method.
  2307. func (c *UsersHistoryListCall) Pages(ctx context.Context, f func(*ListHistoryResponse) error) error {
  2308. c.ctx_ = ctx
  2309. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2310. for {
  2311. x, err := c.Do()
  2312. if err != nil {
  2313. return err
  2314. }
  2315. if err := f(x); err != nil {
  2316. return err
  2317. }
  2318. if x.NextPageToken == "" {
  2319. return nil
  2320. }
  2321. c.PageToken(x.NextPageToken)
  2322. }
  2323. }
  2324. // method id "gmail.users.labels.create":
  2325. type UsersLabelsCreateCall struct {
  2326. s *Service
  2327. userId string
  2328. label *Label
  2329. urlParams_ gensupport.URLParams
  2330. ctx_ context.Context
  2331. }
  2332. // Create: Creates a new label.
  2333. func (r *UsersLabelsService) Create(userId string, label *Label) *UsersLabelsCreateCall {
  2334. c := &UsersLabelsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2335. c.userId = userId
  2336. c.label = label
  2337. return c
  2338. }
  2339. // Fields allows partial responses to be retrieved. See
  2340. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2341. // for more information.
  2342. func (c *UsersLabelsCreateCall) Fields(s ...googleapi.Field) *UsersLabelsCreateCall {
  2343. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2344. return c
  2345. }
  2346. // Context sets the context to be used in this call's Do method. Any
  2347. // pending HTTP request will be aborted if the provided context is
  2348. // canceled.
  2349. func (c *UsersLabelsCreateCall) Context(ctx context.Context) *UsersLabelsCreateCall {
  2350. c.ctx_ = ctx
  2351. return c
  2352. }
  2353. func (c *UsersLabelsCreateCall) doRequest(alt string) (*http.Response, error) {
  2354. var body io.Reader = nil
  2355. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  2356. if err != nil {
  2357. return nil, err
  2358. }
  2359. ctype := "application/json"
  2360. c.urlParams_.Set("alt", alt)
  2361. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
  2362. urls += "?" + c.urlParams_.Encode()
  2363. req, _ := http.NewRequest("POST", urls, body)
  2364. googleapi.Expand(req.URL, map[string]string{
  2365. "userId": c.userId,
  2366. })
  2367. req.Header.Set("Content-Type", ctype)
  2368. req.Header.Set("User-Agent", c.s.userAgent())
  2369. if c.ctx_ != nil {
  2370. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2371. }
  2372. return c.s.client.Do(req)
  2373. }
  2374. // Do executes the "gmail.users.labels.create" call.
  2375. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  2376. // code is an error. Response headers are in either
  2377. // *Label.ServerResponse.Header or (if a response was returned at all)
  2378. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2379. // check whether the returned error was because http.StatusNotModified
  2380. // was returned.
  2381. func (c *UsersLabelsCreateCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  2382. gensupport.SetOptions(c.urlParams_, opts...)
  2383. res, err := c.doRequest("json")
  2384. if res != nil && res.StatusCode == http.StatusNotModified {
  2385. if res.Body != nil {
  2386. res.Body.Close()
  2387. }
  2388. return nil, &googleapi.Error{
  2389. Code: res.StatusCode,
  2390. Header: res.Header,
  2391. }
  2392. }
  2393. if err != nil {
  2394. return nil, err
  2395. }
  2396. defer googleapi.CloseBody(res)
  2397. if err := googleapi.CheckResponse(res); err != nil {
  2398. return nil, err
  2399. }
  2400. ret := &Label{
  2401. ServerResponse: googleapi.ServerResponse{
  2402. Header: res.Header,
  2403. HTTPStatusCode: res.StatusCode,
  2404. },
  2405. }
  2406. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2407. return nil, err
  2408. }
  2409. return ret, nil
  2410. // {
  2411. // "description": "Creates a new label.",
  2412. // "httpMethod": "POST",
  2413. // "id": "gmail.users.labels.create",
  2414. // "parameterOrder": [
  2415. // "userId"
  2416. // ],
  2417. // "parameters": {
  2418. // "userId": {
  2419. // "default": "me",
  2420. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2421. // "location": "path",
  2422. // "required": true,
  2423. // "type": "string"
  2424. // }
  2425. // },
  2426. // "path": "{userId}/labels",
  2427. // "request": {
  2428. // "$ref": "Label"
  2429. // },
  2430. // "response": {
  2431. // "$ref": "Label"
  2432. // },
  2433. // "scopes": [
  2434. // "https://mail.google.com/",
  2435. // "https://www.googleapis.com/auth/gmail.labels",
  2436. // "https://www.googleapis.com/auth/gmail.modify"
  2437. // ]
  2438. // }
  2439. }
  2440. // method id "gmail.users.labels.delete":
  2441. type UsersLabelsDeleteCall struct {
  2442. s *Service
  2443. userId string
  2444. id string
  2445. urlParams_ gensupport.URLParams
  2446. ctx_ context.Context
  2447. }
  2448. // Delete: Immediately and permanently deletes the specified label and
  2449. // removes it from any messages and threads that it is applied to.
  2450. func (r *UsersLabelsService) Delete(userId string, id string) *UsersLabelsDeleteCall {
  2451. c := &UsersLabelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2452. c.userId = userId
  2453. c.id = id
  2454. return c
  2455. }
  2456. // Fields allows partial responses to be retrieved. See
  2457. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2458. // for more information.
  2459. func (c *UsersLabelsDeleteCall) Fields(s ...googleapi.Field) *UsersLabelsDeleteCall {
  2460. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2461. return c
  2462. }
  2463. // Context sets the context to be used in this call's Do method. Any
  2464. // pending HTTP request will be aborted if the provided context is
  2465. // canceled.
  2466. func (c *UsersLabelsDeleteCall) Context(ctx context.Context) *UsersLabelsDeleteCall {
  2467. c.ctx_ = ctx
  2468. return c
  2469. }
  2470. func (c *UsersLabelsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2471. var body io.Reader = nil
  2472. c.urlParams_.Set("alt", alt)
  2473. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  2474. urls += "?" + c.urlParams_.Encode()
  2475. req, _ := http.NewRequest("DELETE", urls, body)
  2476. googleapi.Expand(req.URL, map[string]string{
  2477. "userId": c.userId,
  2478. "id": c.id,
  2479. })
  2480. req.Header.Set("User-Agent", c.s.userAgent())
  2481. if c.ctx_ != nil {
  2482. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2483. }
  2484. return c.s.client.Do(req)
  2485. }
  2486. // Do executes the "gmail.users.labels.delete" call.
  2487. func (c *UsersLabelsDeleteCall) Do(opts ...googleapi.CallOption) error {
  2488. gensupport.SetOptions(c.urlParams_, opts...)
  2489. res, err := c.doRequest("json")
  2490. if err != nil {
  2491. return err
  2492. }
  2493. defer googleapi.CloseBody(res)
  2494. if err := googleapi.CheckResponse(res); err != nil {
  2495. return err
  2496. }
  2497. return nil
  2498. // {
  2499. // "description": "Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.",
  2500. // "httpMethod": "DELETE",
  2501. // "id": "gmail.users.labels.delete",
  2502. // "parameterOrder": [
  2503. // "userId",
  2504. // "id"
  2505. // ],
  2506. // "parameters": {
  2507. // "id": {
  2508. // "description": "The ID of the label to delete.",
  2509. // "location": "path",
  2510. // "required": true,
  2511. // "type": "string"
  2512. // },
  2513. // "userId": {
  2514. // "default": "me",
  2515. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2516. // "location": "path",
  2517. // "required": true,
  2518. // "type": "string"
  2519. // }
  2520. // },
  2521. // "path": "{userId}/labels/{id}",
  2522. // "scopes": [
  2523. // "https://mail.google.com/",
  2524. // "https://www.googleapis.com/auth/gmail.labels",
  2525. // "https://www.googleapis.com/auth/gmail.modify"
  2526. // ]
  2527. // }
  2528. }
  2529. // method id "gmail.users.labels.get":
  2530. type UsersLabelsGetCall struct {
  2531. s *Service
  2532. userId string
  2533. id string
  2534. urlParams_ gensupport.URLParams
  2535. ifNoneMatch_ string
  2536. ctx_ context.Context
  2537. }
  2538. // Get: Gets the specified label.
  2539. func (r *UsersLabelsService) Get(userId string, id string) *UsersLabelsGetCall {
  2540. c := &UsersLabelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2541. c.userId = userId
  2542. c.id = id
  2543. return c
  2544. }
  2545. // Fields allows partial responses to be retrieved. See
  2546. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2547. // for more information.
  2548. func (c *UsersLabelsGetCall) Fields(s ...googleapi.Field) *UsersLabelsGetCall {
  2549. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2550. return c
  2551. }
  2552. // IfNoneMatch sets the optional parameter which makes the operation
  2553. // fail if the object's ETag matches the given value. This is useful for
  2554. // getting updates only after the object has changed since the last
  2555. // request. Use googleapi.IsNotModified to check whether the response
  2556. // error from Do is the result of In-None-Match.
  2557. func (c *UsersLabelsGetCall) IfNoneMatch(entityTag string) *UsersLabelsGetCall {
  2558. c.ifNoneMatch_ = entityTag
  2559. return c
  2560. }
  2561. // Context sets the context to be used in this call's Do method. Any
  2562. // pending HTTP request will be aborted if the provided context is
  2563. // canceled.
  2564. func (c *UsersLabelsGetCall) Context(ctx context.Context) *UsersLabelsGetCall {
  2565. c.ctx_ = ctx
  2566. return c
  2567. }
  2568. func (c *UsersLabelsGetCall) doRequest(alt string) (*http.Response, error) {
  2569. var body io.Reader = nil
  2570. c.urlParams_.Set("alt", alt)
  2571. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  2572. urls += "?" + c.urlParams_.Encode()
  2573. req, _ := http.NewRequest("GET", urls, body)
  2574. googleapi.Expand(req.URL, map[string]string{
  2575. "userId": c.userId,
  2576. "id": c.id,
  2577. })
  2578. req.Header.Set("User-Agent", c.s.userAgent())
  2579. if c.ifNoneMatch_ != "" {
  2580. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2581. }
  2582. if c.ctx_ != nil {
  2583. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2584. }
  2585. return c.s.client.Do(req)
  2586. }
  2587. // Do executes the "gmail.users.labels.get" call.
  2588. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  2589. // code is an error. Response headers are in either
  2590. // *Label.ServerResponse.Header or (if a response was returned at all)
  2591. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2592. // check whether the returned error was because http.StatusNotModified
  2593. // was returned.
  2594. func (c *UsersLabelsGetCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  2595. gensupport.SetOptions(c.urlParams_, opts...)
  2596. res, err := c.doRequest("json")
  2597. if res != nil && res.StatusCode == http.StatusNotModified {
  2598. if res.Body != nil {
  2599. res.Body.Close()
  2600. }
  2601. return nil, &googleapi.Error{
  2602. Code: res.StatusCode,
  2603. Header: res.Header,
  2604. }
  2605. }
  2606. if err != nil {
  2607. return nil, err
  2608. }
  2609. defer googleapi.CloseBody(res)
  2610. if err := googleapi.CheckResponse(res); err != nil {
  2611. return nil, err
  2612. }
  2613. ret := &Label{
  2614. ServerResponse: googleapi.ServerResponse{
  2615. Header: res.Header,
  2616. HTTPStatusCode: res.StatusCode,
  2617. },
  2618. }
  2619. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2620. return nil, err
  2621. }
  2622. return ret, nil
  2623. // {
  2624. // "description": "Gets the specified label.",
  2625. // "httpMethod": "GET",
  2626. // "id": "gmail.users.labels.get",
  2627. // "parameterOrder": [
  2628. // "userId",
  2629. // "id"
  2630. // ],
  2631. // "parameters": {
  2632. // "id": {
  2633. // "description": "The ID of the label to retrieve.",
  2634. // "location": "path",
  2635. // "required": true,
  2636. // "type": "string"
  2637. // },
  2638. // "userId": {
  2639. // "default": "me",
  2640. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2641. // "location": "path",
  2642. // "required": true,
  2643. // "type": "string"
  2644. // }
  2645. // },
  2646. // "path": "{userId}/labels/{id}",
  2647. // "response": {
  2648. // "$ref": "Label"
  2649. // },
  2650. // "scopes": [
  2651. // "https://mail.google.com/",
  2652. // "https://www.googleapis.com/auth/gmail.labels",
  2653. // "https://www.googleapis.com/auth/gmail.modify",
  2654. // "https://www.googleapis.com/auth/gmail.readonly"
  2655. // ]
  2656. // }
  2657. }
  2658. // method id "gmail.users.labels.list":
  2659. type UsersLabelsListCall struct {
  2660. s *Service
  2661. userId string
  2662. urlParams_ gensupport.URLParams
  2663. ifNoneMatch_ string
  2664. ctx_ context.Context
  2665. }
  2666. // List: Lists all labels in the user's mailbox.
  2667. func (r *UsersLabelsService) List(userId string) *UsersLabelsListCall {
  2668. c := &UsersLabelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2669. c.userId = userId
  2670. return c
  2671. }
  2672. // Fields allows partial responses to be retrieved. See
  2673. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2674. // for more information.
  2675. func (c *UsersLabelsListCall) Fields(s ...googleapi.Field) *UsersLabelsListCall {
  2676. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2677. return c
  2678. }
  2679. // IfNoneMatch sets the optional parameter which makes the operation
  2680. // fail if the object's ETag matches the given value. This is useful for
  2681. // getting updates only after the object has changed since the last
  2682. // request. Use googleapi.IsNotModified to check whether the response
  2683. // error from Do is the result of In-None-Match.
  2684. func (c *UsersLabelsListCall) IfNoneMatch(entityTag string) *UsersLabelsListCall {
  2685. c.ifNoneMatch_ = entityTag
  2686. return c
  2687. }
  2688. // Context sets the context to be used in this call's Do method. Any
  2689. // pending HTTP request will be aborted if the provided context is
  2690. // canceled.
  2691. func (c *UsersLabelsListCall) Context(ctx context.Context) *UsersLabelsListCall {
  2692. c.ctx_ = ctx
  2693. return c
  2694. }
  2695. func (c *UsersLabelsListCall) doRequest(alt string) (*http.Response, error) {
  2696. var body io.Reader = nil
  2697. c.urlParams_.Set("alt", alt)
  2698. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels")
  2699. urls += "?" + c.urlParams_.Encode()
  2700. req, _ := http.NewRequest("GET", urls, body)
  2701. googleapi.Expand(req.URL, map[string]string{
  2702. "userId": c.userId,
  2703. })
  2704. req.Header.Set("User-Agent", c.s.userAgent())
  2705. if c.ifNoneMatch_ != "" {
  2706. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2707. }
  2708. if c.ctx_ != nil {
  2709. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2710. }
  2711. return c.s.client.Do(req)
  2712. }
  2713. // Do executes the "gmail.users.labels.list" call.
  2714. // Exactly one of *ListLabelsResponse or error will be non-nil. Any
  2715. // non-2xx status code is an error. Response headers are in either
  2716. // *ListLabelsResponse.ServerResponse.Header or (if a response was
  2717. // returned at all) in error.(*googleapi.Error).Header. Use
  2718. // googleapi.IsNotModified to check whether the returned error was
  2719. // because http.StatusNotModified was returned.
  2720. func (c *UsersLabelsListCall) Do(opts ...googleapi.CallOption) (*ListLabelsResponse, error) {
  2721. gensupport.SetOptions(c.urlParams_, opts...)
  2722. res, err := c.doRequest("json")
  2723. if res != nil && res.StatusCode == http.StatusNotModified {
  2724. if res.Body != nil {
  2725. res.Body.Close()
  2726. }
  2727. return nil, &googleapi.Error{
  2728. Code: res.StatusCode,
  2729. Header: res.Header,
  2730. }
  2731. }
  2732. if err != nil {
  2733. return nil, err
  2734. }
  2735. defer googleapi.CloseBody(res)
  2736. if err := googleapi.CheckResponse(res); err != nil {
  2737. return nil, err
  2738. }
  2739. ret := &ListLabelsResponse{
  2740. ServerResponse: googleapi.ServerResponse{
  2741. Header: res.Header,
  2742. HTTPStatusCode: res.StatusCode,
  2743. },
  2744. }
  2745. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2746. return nil, err
  2747. }
  2748. return ret, nil
  2749. // {
  2750. // "description": "Lists all labels in the user's mailbox.",
  2751. // "httpMethod": "GET",
  2752. // "id": "gmail.users.labels.list",
  2753. // "parameterOrder": [
  2754. // "userId"
  2755. // ],
  2756. // "parameters": {
  2757. // "userId": {
  2758. // "default": "me",
  2759. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2760. // "location": "path",
  2761. // "required": true,
  2762. // "type": "string"
  2763. // }
  2764. // },
  2765. // "path": "{userId}/labels",
  2766. // "response": {
  2767. // "$ref": "ListLabelsResponse"
  2768. // },
  2769. // "scopes": [
  2770. // "https://mail.google.com/",
  2771. // "https://www.googleapis.com/auth/gmail.labels",
  2772. // "https://www.googleapis.com/auth/gmail.modify",
  2773. // "https://www.googleapis.com/auth/gmail.readonly"
  2774. // ]
  2775. // }
  2776. }
  2777. // method id "gmail.users.labels.patch":
  2778. type UsersLabelsPatchCall struct {
  2779. s *Service
  2780. userId string
  2781. id string
  2782. label *Label
  2783. urlParams_ gensupport.URLParams
  2784. ctx_ context.Context
  2785. }
  2786. // Patch: Updates the specified label. This method supports patch
  2787. // semantics.
  2788. func (r *UsersLabelsService) Patch(userId string, id string, label *Label) *UsersLabelsPatchCall {
  2789. c := &UsersLabelsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2790. c.userId = userId
  2791. c.id = id
  2792. c.label = label
  2793. return c
  2794. }
  2795. // Fields allows partial responses to be retrieved. See
  2796. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2797. // for more information.
  2798. func (c *UsersLabelsPatchCall) Fields(s ...googleapi.Field) *UsersLabelsPatchCall {
  2799. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2800. return c
  2801. }
  2802. // Context sets the context to be used in this call's Do method. Any
  2803. // pending HTTP request will be aborted if the provided context is
  2804. // canceled.
  2805. func (c *UsersLabelsPatchCall) Context(ctx context.Context) *UsersLabelsPatchCall {
  2806. c.ctx_ = ctx
  2807. return c
  2808. }
  2809. func (c *UsersLabelsPatchCall) doRequest(alt string) (*http.Response, error) {
  2810. var body io.Reader = nil
  2811. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  2812. if err != nil {
  2813. return nil, err
  2814. }
  2815. ctype := "application/json"
  2816. c.urlParams_.Set("alt", alt)
  2817. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  2818. urls += "?" + c.urlParams_.Encode()
  2819. req, _ := http.NewRequest("PATCH", urls, body)
  2820. googleapi.Expand(req.URL, map[string]string{
  2821. "userId": c.userId,
  2822. "id": c.id,
  2823. })
  2824. req.Header.Set("Content-Type", ctype)
  2825. req.Header.Set("User-Agent", c.s.userAgent())
  2826. if c.ctx_ != nil {
  2827. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2828. }
  2829. return c.s.client.Do(req)
  2830. }
  2831. // Do executes the "gmail.users.labels.patch" call.
  2832. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  2833. // code is an error. Response headers are in either
  2834. // *Label.ServerResponse.Header or (if a response was returned at all)
  2835. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2836. // check whether the returned error was because http.StatusNotModified
  2837. // was returned.
  2838. func (c *UsersLabelsPatchCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  2839. gensupport.SetOptions(c.urlParams_, opts...)
  2840. res, err := c.doRequest("json")
  2841. if res != nil && res.StatusCode == http.StatusNotModified {
  2842. if res.Body != nil {
  2843. res.Body.Close()
  2844. }
  2845. return nil, &googleapi.Error{
  2846. Code: res.StatusCode,
  2847. Header: res.Header,
  2848. }
  2849. }
  2850. if err != nil {
  2851. return nil, err
  2852. }
  2853. defer googleapi.CloseBody(res)
  2854. if err := googleapi.CheckResponse(res); err != nil {
  2855. return nil, err
  2856. }
  2857. ret := &Label{
  2858. ServerResponse: googleapi.ServerResponse{
  2859. Header: res.Header,
  2860. HTTPStatusCode: res.StatusCode,
  2861. },
  2862. }
  2863. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2864. return nil, err
  2865. }
  2866. return ret, nil
  2867. // {
  2868. // "description": "Updates the specified label. This method supports patch semantics.",
  2869. // "httpMethod": "PATCH",
  2870. // "id": "gmail.users.labels.patch",
  2871. // "parameterOrder": [
  2872. // "userId",
  2873. // "id"
  2874. // ],
  2875. // "parameters": {
  2876. // "id": {
  2877. // "description": "The ID of the label to update.",
  2878. // "location": "path",
  2879. // "required": true,
  2880. // "type": "string"
  2881. // },
  2882. // "userId": {
  2883. // "default": "me",
  2884. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  2885. // "location": "path",
  2886. // "required": true,
  2887. // "type": "string"
  2888. // }
  2889. // },
  2890. // "path": "{userId}/labels/{id}",
  2891. // "request": {
  2892. // "$ref": "Label"
  2893. // },
  2894. // "response": {
  2895. // "$ref": "Label"
  2896. // },
  2897. // "scopes": [
  2898. // "https://mail.google.com/",
  2899. // "https://www.googleapis.com/auth/gmail.labels",
  2900. // "https://www.googleapis.com/auth/gmail.modify"
  2901. // ]
  2902. // }
  2903. }
  2904. // method id "gmail.users.labels.update":
  2905. type UsersLabelsUpdateCall struct {
  2906. s *Service
  2907. userId string
  2908. id string
  2909. label *Label
  2910. urlParams_ gensupport.URLParams
  2911. ctx_ context.Context
  2912. }
  2913. // Update: Updates the specified label.
  2914. func (r *UsersLabelsService) Update(userId string, id string, label *Label) *UsersLabelsUpdateCall {
  2915. c := &UsersLabelsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2916. c.userId = userId
  2917. c.id = id
  2918. c.label = label
  2919. return c
  2920. }
  2921. // Fields allows partial responses to be retrieved. See
  2922. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2923. // for more information.
  2924. func (c *UsersLabelsUpdateCall) Fields(s ...googleapi.Field) *UsersLabelsUpdateCall {
  2925. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2926. return c
  2927. }
  2928. // Context sets the context to be used in this call's Do method. Any
  2929. // pending HTTP request will be aborted if the provided context is
  2930. // canceled.
  2931. func (c *UsersLabelsUpdateCall) Context(ctx context.Context) *UsersLabelsUpdateCall {
  2932. c.ctx_ = ctx
  2933. return c
  2934. }
  2935. func (c *UsersLabelsUpdateCall) doRequest(alt string) (*http.Response, error) {
  2936. var body io.Reader = nil
  2937. body, err := googleapi.WithoutDataWrapper.JSONReader(c.label)
  2938. if err != nil {
  2939. return nil, err
  2940. }
  2941. ctype := "application/json"
  2942. c.urlParams_.Set("alt", alt)
  2943. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/labels/{id}")
  2944. urls += "?" + c.urlParams_.Encode()
  2945. req, _ := http.NewRequest("PUT", urls, body)
  2946. googleapi.Expand(req.URL, map[string]string{
  2947. "userId": c.userId,
  2948. "id": c.id,
  2949. })
  2950. req.Header.Set("Content-Type", ctype)
  2951. req.Header.Set("User-Agent", c.s.userAgent())
  2952. if c.ctx_ != nil {
  2953. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2954. }
  2955. return c.s.client.Do(req)
  2956. }
  2957. // Do executes the "gmail.users.labels.update" call.
  2958. // Exactly one of *Label or error will be non-nil. Any non-2xx status
  2959. // code is an error. Response headers are in either
  2960. // *Label.ServerResponse.Header or (if a response was returned at all)
  2961. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2962. // check whether the returned error was because http.StatusNotModified
  2963. // was returned.
  2964. func (c *UsersLabelsUpdateCall) Do(opts ...googleapi.CallOption) (*Label, error) {
  2965. gensupport.SetOptions(c.urlParams_, opts...)
  2966. res, err := c.doRequest("json")
  2967. if res != nil && res.StatusCode == http.StatusNotModified {
  2968. if res.Body != nil {
  2969. res.Body.Close()
  2970. }
  2971. return nil, &googleapi.Error{
  2972. Code: res.StatusCode,
  2973. Header: res.Header,
  2974. }
  2975. }
  2976. if err != nil {
  2977. return nil, err
  2978. }
  2979. defer googleapi.CloseBody(res)
  2980. if err := googleapi.CheckResponse(res); err != nil {
  2981. return nil, err
  2982. }
  2983. ret := &Label{
  2984. ServerResponse: googleapi.ServerResponse{
  2985. Header: res.Header,
  2986. HTTPStatusCode: res.StatusCode,
  2987. },
  2988. }
  2989. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2990. return nil, err
  2991. }
  2992. return ret, nil
  2993. // {
  2994. // "description": "Updates the specified label.",
  2995. // "httpMethod": "PUT",
  2996. // "id": "gmail.users.labels.update",
  2997. // "parameterOrder": [
  2998. // "userId",
  2999. // "id"
  3000. // ],
  3001. // "parameters": {
  3002. // "id": {
  3003. // "description": "The ID of the label to update.",
  3004. // "location": "path",
  3005. // "required": true,
  3006. // "type": "string"
  3007. // },
  3008. // "userId": {
  3009. // "default": "me",
  3010. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3011. // "location": "path",
  3012. // "required": true,
  3013. // "type": "string"
  3014. // }
  3015. // },
  3016. // "path": "{userId}/labels/{id}",
  3017. // "request": {
  3018. // "$ref": "Label"
  3019. // },
  3020. // "response": {
  3021. // "$ref": "Label"
  3022. // },
  3023. // "scopes": [
  3024. // "https://mail.google.com/",
  3025. // "https://www.googleapis.com/auth/gmail.labels",
  3026. // "https://www.googleapis.com/auth/gmail.modify"
  3027. // ]
  3028. // }
  3029. }
  3030. // method id "gmail.users.messages.delete":
  3031. type UsersMessagesDeleteCall struct {
  3032. s *Service
  3033. userId string
  3034. id string
  3035. urlParams_ gensupport.URLParams
  3036. ctx_ context.Context
  3037. }
  3038. // Delete: Immediately and permanently deletes the specified message.
  3039. // This operation cannot be undone. Prefer messages.trash instead.
  3040. func (r *UsersMessagesService) Delete(userId string, id string) *UsersMessagesDeleteCall {
  3041. c := &UsersMessagesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3042. c.userId = userId
  3043. c.id = id
  3044. return c
  3045. }
  3046. // Fields allows partial responses to be retrieved. See
  3047. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3048. // for more information.
  3049. func (c *UsersMessagesDeleteCall) Fields(s ...googleapi.Field) *UsersMessagesDeleteCall {
  3050. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3051. return c
  3052. }
  3053. // Context sets the context to be used in this call's Do method. Any
  3054. // pending HTTP request will be aborted if the provided context is
  3055. // canceled.
  3056. func (c *UsersMessagesDeleteCall) Context(ctx context.Context) *UsersMessagesDeleteCall {
  3057. c.ctx_ = ctx
  3058. return c
  3059. }
  3060. func (c *UsersMessagesDeleteCall) doRequest(alt string) (*http.Response, error) {
  3061. var body io.Reader = nil
  3062. c.urlParams_.Set("alt", alt)
  3063. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
  3064. urls += "?" + c.urlParams_.Encode()
  3065. req, _ := http.NewRequest("DELETE", urls, body)
  3066. googleapi.Expand(req.URL, map[string]string{
  3067. "userId": c.userId,
  3068. "id": c.id,
  3069. })
  3070. req.Header.Set("User-Agent", c.s.userAgent())
  3071. if c.ctx_ != nil {
  3072. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3073. }
  3074. return c.s.client.Do(req)
  3075. }
  3076. // Do executes the "gmail.users.messages.delete" call.
  3077. func (c *UsersMessagesDeleteCall) Do(opts ...googleapi.CallOption) error {
  3078. gensupport.SetOptions(c.urlParams_, opts...)
  3079. res, err := c.doRequest("json")
  3080. if err != nil {
  3081. return err
  3082. }
  3083. defer googleapi.CloseBody(res)
  3084. if err := googleapi.CheckResponse(res); err != nil {
  3085. return err
  3086. }
  3087. return nil
  3088. // {
  3089. // "description": "Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer messages.trash instead.",
  3090. // "httpMethod": "DELETE",
  3091. // "id": "gmail.users.messages.delete",
  3092. // "parameterOrder": [
  3093. // "userId",
  3094. // "id"
  3095. // ],
  3096. // "parameters": {
  3097. // "id": {
  3098. // "description": "The ID of the message to delete.",
  3099. // "location": "path",
  3100. // "required": true,
  3101. // "type": "string"
  3102. // },
  3103. // "userId": {
  3104. // "default": "me",
  3105. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3106. // "location": "path",
  3107. // "required": true,
  3108. // "type": "string"
  3109. // }
  3110. // },
  3111. // "path": "{userId}/messages/{id}",
  3112. // "scopes": [
  3113. // "https://mail.google.com/"
  3114. // ]
  3115. // }
  3116. }
  3117. // method id "gmail.users.messages.get":
  3118. type UsersMessagesGetCall struct {
  3119. s *Service
  3120. userId string
  3121. id string
  3122. urlParams_ gensupport.URLParams
  3123. ifNoneMatch_ string
  3124. ctx_ context.Context
  3125. }
  3126. // Get: Gets the specified message.
  3127. func (r *UsersMessagesService) Get(userId string, id string) *UsersMessagesGetCall {
  3128. c := &UsersMessagesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3129. c.userId = userId
  3130. c.id = id
  3131. return c
  3132. }
  3133. // Format sets the optional parameter "format": The format to return the
  3134. // message in.
  3135. //
  3136. // Possible values:
  3137. // "full" (default)
  3138. // "metadata"
  3139. // "minimal"
  3140. // "raw"
  3141. func (c *UsersMessagesGetCall) Format(format string) *UsersMessagesGetCall {
  3142. c.urlParams_.Set("format", format)
  3143. return c
  3144. }
  3145. // MetadataHeaders sets the optional parameter "metadataHeaders": When
  3146. // given and format is METADATA, only include headers specified.
  3147. func (c *UsersMessagesGetCall) MetadataHeaders(metadataHeaders ...string) *UsersMessagesGetCall {
  3148. c.urlParams_.SetMulti("metadataHeaders", append([]string{}, metadataHeaders...))
  3149. return c
  3150. }
  3151. // Fields allows partial responses to be retrieved. See
  3152. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3153. // for more information.
  3154. func (c *UsersMessagesGetCall) Fields(s ...googleapi.Field) *UsersMessagesGetCall {
  3155. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3156. return c
  3157. }
  3158. // IfNoneMatch sets the optional parameter which makes the operation
  3159. // fail if the object's ETag matches the given value. This is useful for
  3160. // getting updates only after the object has changed since the last
  3161. // request. Use googleapi.IsNotModified to check whether the response
  3162. // error from Do is the result of In-None-Match.
  3163. func (c *UsersMessagesGetCall) IfNoneMatch(entityTag string) *UsersMessagesGetCall {
  3164. c.ifNoneMatch_ = entityTag
  3165. return c
  3166. }
  3167. // Context sets the context to be used in this call's Do method. Any
  3168. // pending HTTP request will be aborted if the provided context is
  3169. // canceled.
  3170. func (c *UsersMessagesGetCall) Context(ctx context.Context) *UsersMessagesGetCall {
  3171. c.ctx_ = ctx
  3172. return c
  3173. }
  3174. func (c *UsersMessagesGetCall) doRequest(alt string) (*http.Response, error) {
  3175. var body io.Reader = nil
  3176. c.urlParams_.Set("alt", alt)
  3177. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}")
  3178. urls += "?" + c.urlParams_.Encode()
  3179. req, _ := http.NewRequest("GET", urls, body)
  3180. googleapi.Expand(req.URL, map[string]string{
  3181. "userId": c.userId,
  3182. "id": c.id,
  3183. })
  3184. req.Header.Set("User-Agent", c.s.userAgent())
  3185. if c.ifNoneMatch_ != "" {
  3186. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  3187. }
  3188. if c.ctx_ != nil {
  3189. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3190. }
  3191. return c.s.client.Do(req)
  3192. }
  3193. // Do executes the "gmail.users.messages.get" call.
  3194. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  3195. // code is an error. Response headers are in either
  3196. // *Message.ServerResponse.Header or (if a response was returned at all)
  3197. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3198. // check whether the returned error was because http.StatusNotModified
  3199. // was returned.
  3200. func (c *UsersMessagesGetCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  3201. gensupport.SetOptions(c.urlParams_, opts...)
  3202. res, err := c.doRequest("json")
  3203. if res != nil && res.StatusCode == http.StatusNotModified {
  3204. if res.Body != nil {
  3205. res.Body.Close()
  3206. }
  3207. return nil, &googleapi.Error{
  3208. Code: res.StatusCode,
  3209. Header: res.Header,
  3210. }
  3211. }
  3212. if err != nil {
  3213. return nil, err
  3214. }
  3215. defer googleapi.CloseBody(res)
  3216. if err := googleapi.CheckResponse(res); err != nil {
  3217. return nil, err
  3218. }
  3219. ret := &Message{
  3220. ServerResponse: googleapi.ServerResponse{
  3221. Header: res.Header,
  3222. HTTPStatusCode: res.StatusCode,
  3223. },
  3224. }
  3225. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3226. return nil, err
  3227. }
  3228. return ret, nil
  3229. // {
  3230. // "description": "Gets the specified message.",
  3231. // "httpMethod": "GET",
  3232. // "id": "gmail.users.messages.get",
  3233. // "parameterOrder": [
  3234. // "userId",
  3235. // "id"
  3236. // ],
  3237. // "parameters": {
  3238. // "format": {
  3239. // "default": "full",
  3240. // "description": "The format to return the message in.",
  3241. // "enum": [
  3242. // "full",
  3243. // "metadata",
  3244. // "minimal",
  3245. // "raw"
  3246. // ],
  3247. // "enumDescriptions": [
  3248. // "",
  3249. // "",
  3250. // "",
  3251. // ""
  3252. // ],
  3253. // "location": "query",
  3254. // "type": "string"
  3255. // },
  3256. // "id": {
  3257. // "description": "The ID of the message to retrieve.",
  3258. // "location": "path",
  3259. // "required": true,
  3260. // "type": "string"
  3261. // },
  3262. // "metadataHeaders": {
  3263. // "description": "When given and format is METADATA, only include headers specified.",
  3264. // "location": "query",
  3265. // "repeated": true,
  3266. // "type": "string"
  3267. // },
  3268. // "userId": {
  3269. // "default": "me",
  3270. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3271. // "location": "path",
  3272. // "required": true,
  3273. // "type": "string"
  3274. // }
  3275. // },
  3276. // "path": "{userId}/messages/{id}",
  3277. // "response": {
  3278. // "$ref": "Message"
  3279. // },
  3280. // "scopes": [
  3281. // "https://mail.google.com/",
  3282. // "https://www.googleapis.com/auth/gmail.modify",
  3283. // "https://www.googleapis.com/auth/gmail.readonly"
  3284. // ]
  3285. // }
  3286. }
  3287. // method id "gmail.users.messages.import":
  3288. type UsersMessagesImportCall struct {
  3289. s *Service
  3290. userId string
  3291. message *Message
  3292. urlParams_ gensupport.URLParams
  3293. media_ io.Reader
  3294. resumableBuffer_ *gensupport.ResumableBuffer
  3295. mediaType_ string
  3296. mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_.
  3297. progressUpdater_ googleapi.ProgressUpdater
  3298. ctx_ context.Context
  3299. }
  3300. // Import: Imports a message into only this user's mailbox, with
  3301. // standard email delivery scanning and classification similar to
  3302. // receiving via SMTP. Does not send a message.
  3303. func (r *UsersMessagesService) Import(userId string, message *Message) *UsersMessagesImportCall {
  3304. c := &UsersMessagesImportCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3305. c.userId = userId
  3306. c.message = message
  3307. return c
  3308. }
  3309. // Deleted sets the optional parameter "deleted": Mark the email as
  3310. // permanently deleted (not TRASH) and only visible in Google Apps Vault
  3311. // to a Vault administrator. Only used for Google Apps for Work
  3312. // accounts.
  3313. func (c *UsersMessagesImportCall) Deleted(deleted bool) *UsersMessagesImportCall {
  3314. c.urlParams_.Set("deleted", fmt.Sprint(deleted))
  3315. return c
  3316. }
  3317. // InternalDateSource sets the optional parameter "internalDateSource":
  3318. // Source for Gmail's internal date of the message.
  3319. //
  3320. // Possible values:
  3321. // "dateHeader" (default)
  3322. // "receivedTime"
  3323. func (c *UsersMessagesImportCall) InternalDateSource(internalDateSource string) *UsersMessagesImportCall {
  3324. c.urlParams_.Set("internalDateSource", internalDateSource)
  3325. return c
  3326. }
  3327. // NeverMarkSpam sets the optional parameter "neverMarkSpam": Ignore the
  3328. // Gmail spam classifier decision and never mark this email as SPAM in
  3329. // the mailbox.
  3330. func (c *UsersMessagesImportCall) NeverMarkSpam(neverMarkSpam bool) *UsersMessagesImportCall {
  3331. c.urlParams_.Set("neverMarkSpam", fmt.Sprint(neverMarkSpam))
  3332. return c
  3333. }
  3334. // ProcessForCalendar sets the optional parameter "processForCalendar":
  3335. // Process calendar invites in the email and add any extracted meetings
  3336. // to the Google Calendar for this user.
  3337. func (c *UsersMessagesImportCall) ProcessForCalendar(processForCalendar bool) *UsersMessagesImportCall {
  3338. c.urlParams_.Set("processForCalendar", fmt.Sprint(processForCalendar))
  3339. return c
  3340. }
  3341. // Media specifies the media to upload in one or more chunks. The chunk
  3342. // size may be controlled by supplying a MediaOption generated by
  3343. // googleapi.ChunkSize. The chunk size defaults to
  3344. // googleapi.DefaultUploadChunkSize.
  3345. // At most one of Media and ResumableMedia may be set.
  3346. func (c *UsersMessagesImportCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesImportCall {
  3347. opts := googleapi.ProcessMediaOptions(options)
  3348. chunkSize := opts.ChunkSize
  3349. r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)
  3350. c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)
  3351. return c
  3352. }
  3353. // ResumableMedia specifies the media to upload in chunks and can be
  3354. // canceled with ctx.
  3355. //
  3356. // Deprecated: use Media instead.
  3357. //
  3358. // At most one of Media and ResumableMedia may be set. mediaType
  3359. // identifies the MIME media type of the upload, such as "image/png". If
  3360. // mediaType is "", it will be auto-detected. The provided ctx will
  3361. // supersede any context previously provided to the Context method.
  3362. func (c *UsersMessagesImportCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesImportCall {
  3363. c.ctx_ = ctx
  3364. rdr := gensupport.ReaderAtToReader(r, size)
  3365. rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)
  3366. c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)
  3367. c.media_ = nil
  3368. c.mediaSize_ = size
  3369. return c
  3370. }
  3371. // ProgressUpdater provides a callback function that will be called
  3372. // after every chunk. It should be a low-latency function in order to
  3373. // not slow down the upload operation. This should only be called when
  3374. // using ResumableMedia (as opposed to Media).
  3375. func (c *UsersMessagesImportCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesImportCall {
  3376. c.progressUpdater_ = pu
  3377. return c
  3378. }
  3379. // Fields allows partial responses to be retrieved. See
  3380. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3381. // for more information.
  3382. func (c *UsersMessagesImportCall) Fields(s ...googleapi.Field) *UsersMessagesImportCall {
  3383. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3384. return c
  3385. }
  3386. // Context sets the context to be used in this call's Do method. Any
  3387. // pending HTTP request will be aborted if the provided context is
  3388. // canceled.
  3389. // This context will supersede any context previously provided to the
  3390. // ResumableMedia method.
  3391. func (c *UsersMessagesImportCall) Context(ctx context.Context) *UsersMessagesImportCall {
  3392. c.ctx_ = ctx
  3393. return c
  3394. }
  3395. func (c *UsersMessagesImportCall) doRequest(alt string) (*http.Response, error) {
  3396. var body io.Reader = nil
  3397. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  3398. if err != nil {
  3399. return nil, err
  3400. }
  3401. ctype := "application/json"
  3402. c.urlParams_.Set("alt", alt)
  3403. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/import")
  3404. if c.media_ != nil || c.resumableBuffer_ != nil {
  3405. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  3406. protocol := "multipart"
  3407. if c.resumableBuffer_ != nil {
  3408. protocol = "resumable"
  3409. }
  3410. c.urlParams_.Set("uploadType", protocol)
  3411. }
  3412. urls += "?" + c.urlParams_.Encode()
  3413. if c.media_ != nil {
  3414. var combined io.ReadCloser
  3415. combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)
  3416. defer combined.Close()
  3417. body = combined
  3418. }
  3419. req, _ := http.NewRequest("POST", urls, body)
  3420. googleapi.Expand(req.URL, map[string]string{
  3421. "userId": c.userId,
  3422. })
  3423. if c.resumableBuffer_ != nil {
  3424. req.Header.Set("X-Upload-Content-Type", c.mediaType_)
  3425. }
  3426. req.Header.Set("Content-Type", ctype)
  3427. req.Header.Set("User-Agent", c.s.userAgent())
  3428. if c.ctx_ != nil {
  3429. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3430. }
  3431. return c.s.client.Do(req)
  3432. }
  3433. // Do executes the "gmail.users.messages.import" call.
  3434. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  3435. // code is an error. Response headers are in either
  3436. // *Message.ServerResponse.Header or (if a response was returned at all)
  3437. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3438. // check whether the returned error was because http.StatusNotModified
  3439. // was returned.
  3440. func (c *UsersMessagesImportCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  3441. gensupport.SetOptions(c.urlParams_, opts...)
  3442. res, err := gensupport.Retry(c.ctx_, func() (*http.Response, error) {
  3443. return c.doRequest("json")
  3444. }, gensupport.DefaultBackoffStrategy())
  3445. if res != nil && res.StatusCode == http.StatusNotModified {
  3446. if res.Body != nil {
  3447. res.Body.Close()
  3448. }
  3449. return nil, &googleapi.Error{
  3450. Code: res.StatusCode,
  3451. Header: res.Header,
  3452. }
  3453. }
  3454. if err != nil {
  3455. return nil, err
  3456. }
  3457. defer googleapi.CloseBody(res)
  3458. if err := googleapi.CheckResponse(res); err != nil {
  3459. return nil, err
  3460. }
  3461. if c.resumableBuffer_ != nil {
  3462. loc := res.Header.Get("Location")
  3463. rx := &gensupport.ResumableUpload{
  3464. Client: c.s.client,
  3465. UserAgent: c.s.userAgent(),
  3466. URI: loc,
  3467. Media: c.resumableBuffer_,
  3468. MediaType: c.mediaType_,
  3469. Callback: func(curr int64) {
  3470. if c.progressUpdater_ != nil {
  3471. c.progressUpdater_(curr, c.mediaSize_)
  3472. }
  3473. },
  3474. }
  3475. ctx := c.ctx_
  3476. if ctx == nil {
  3477. ctx = context.TODO()
  3478. }
  3479. res, err = rx.Upload(ctx)
  3480. if err != nil {
  3481. return nil, err
  3482. }
  3483. defer res.Body.Close()
  3484. if err := googleapi.CheckResponse(res); err != nil {
  3485. return nil, err
  3486. }
  3487. }
  3488. ret := &Message{
  3489. ServerResponse: googleapi.ServerResponse{
  3490. Header: res.Header,
  3491. HTTPStatusCode: res.StatusCode,
  3492. },
  3493. }
  3494. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3495. return nil, err
  3496. }
  3497. return ret, nil
  3498. // {
  3499. // "description": "Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. Does not send a message.",
  3500. // "httpMethod": "POST",
  3501. // "id": "gmail.users.messages.import",
  3502. // "mediaUpload": {
  3503. // "accept": [
  3504. // "message/rfc822"
  3505. // ],
  3506. // "maxSize": "35MB",
  3507. // "protocols": {
  3508. // "resumable": {
  3509. // "multipart": true,
  3510. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages/import"
  3511. // },
  3512. // "simple": {
  3513. // "multipart": true,
  3514. // "path": "/upload/gmail/v1/users/{userId}/messages/import"
  3515. // }
  3516. // }
  3517. // },
  3518. // "parameterOrder": [
  3519. // "userId"
  3520. // ],
  3521. // "parameters": {
  3522. // "deleted": {
  3523. // "default": "false",
  3524. // "description": "Mark the email as permanently deleted (not TRASH) and only visible in Google Apps Vault to a Vault administrator. Only used for Google Apps for Work accounts.",
  3525. // "location": "query",
  3526. // "type": "boolean"
  3527. // },
  3528. // "internalDateSource": {
  3529. // "default": "dateHeader",
  3530. // "description": "Source for Gmail's internal date of the message.",
  3531. // "enum": [
  3532. // "dateHeader",
  3533. // "receivedTime"
  3534. // ],
  3535. // "enumDescriptions": [
  3536. // "",
  3537. // ""
  3538. // ],
  3539. // "location": "query",
  3540. // "type": "string"
  3541. // },
  3542. // "neverMarkSpam": {
  3543. // "default": "false",
  3544. // "description": "Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.",
  3545. // "location": "query",
  3546. // "type": "boolean"
  3547. // },
  3548. // "processForCalendar": {
  3549. // "default": "false",
  3550. // "description": "Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.",
  3551. // "location": "query",
  3552. // "type": "boolean"
  3553. // },
  3554. // "userId": {
  3555. // "default": "me",
  3556. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3557. // "location": "path",
  3558. // "required": true,
  3559. // "type": "string"
  3560. // }
  3561. // },
  3562. // "path": "{userId}/messages/import",
  3563. // "request": {
  3564. // "$ref": "Message"
  3565. // },
  3566. // "response": {
  3567. // "$ref": "Message"
  3568. // },
  3569. // "scopes": [
  3570. // "https://mail.google.com/",
  3571. // "https://www.googleapis.com/auth/gmail.insert",
  3572. // "https://www.googleapis.com/auth/gmail.modify"
  3573. // ],
  3574. // "supportsMediaUpload": true
  3575. // }
  3576. }
  3577. // method id "gmail.users.messages.insert":
  3578. type UsersMessagesInsertCall struct {
  3579. s *Service
  3580. userId string
  3581. message *Message
  3582. urlParams_ gensupport.URLParams
  3583. media_ io.Reader
  3584. resumableBuffer_ *gensupport.ResumableBuffer
  3585. mediaType_ string
  3586. mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_.
  3587. progressUpdater_ googleapi.ProgressUpdater
  3588. ctx_ context.Context
  3589. }
  3590. // Insert: Directly inserts a message into only this user's mailbox
  3591. // similar to IMAP APPEND, bypassing most scanning and classification.
  3592. // Does not send a message.
  3593. func (r *UsersMessagesService) Insert(userId string, message *Message) *UsersMessagesInsertCall {
  3594. c := &UsersMessagesInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3595. c.userId = userId
  3596. c.message = message
  3597. return c
  3598. }
  3599. // Deleted sets the optional parameter "deleted": Mark the email as
  3600. // permanently deleted (not TRASH) and only visible in Google Apps Vault
  3601. // to a Vault administrator. Only used for Google Apps for Work
  3602. // accounts.
  3603. func (c *UsersMessagesInsertCall) Deleted(deleted bool) *UsersMessagesInsertCall {
  3604. c.urlParams_.Set("deleted", fmt.Sprint(deleted))
  3605. return c
  3606. }
  3607. // InternalDateSource sets the optional parameter "internalDateSource":
  3608. // Source for Gmail's internal date of the message.
  3609. //
  3610. // Possible values:
  3611. // "dateHeader"
  3612. // "receivedTime" (default)
  3613. func (c *UsersMessagesInsertCall) InternalDateSource(internalDateSource string) *UsersMessagesInsertCall {
  3614. c.urlParams_.Set("internalDateSource", internalDateSource)
  3615. return c
  3616. }
  3617. // Media specifies the media to upload in one or more chunks. The chunk
  3618. // size may be controlled by supplying a MediaOption generated by
  3619. // googleapi.ChunkSize. The chunk size defaults to
  3620. // googleapi.DefaultUploadChunkSize.
  3621. // At most one of Media and ResumableMedia may be set.
  3622. func (c *UsersMessagesInsertCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesInsertCall {
  3623. opts := googleapi.ProcessMediaOptions(options)
  3624. chunkSize := opts.ChunkSize
  3625. r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)
  3626. c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)
  3627. return c
  3628. }
  3629. // ResumableMedia specifies the media to upload in chunks and can be
  3630. // canceled with ctx.
  3631. //
  3632. // Deprecated: use Media instead.
  3633. //
  3634. // At most one of Media and ResumableMedia may be set. mediaType
  3635. // identifies the MIME media type of the upload, such as "image/png". If
  3636. // mediaType is "", it will be auto-detected. The provided ctx will
  3637. // supersede any context previously provided to the Context method.
  3638. func (c *UsersMessagesInsertCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesInsertCall {
  3639. c.ctx_ = ctx
  3640. rdr := gensupport.ReaderAtToReader(r, size)
  3641. rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)
  3642. c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)
  3643. c.media_ = nil
  3644. c.mediaSize_ = size
  3645. return c
  3646. }
  3647. // ProgressUpdater provides a callback function that will be called
  3648. // after every chunk. It should be a low-latency function in order to
  3649. // not slow down the upload operation. This should only be called when
  3650. // using ResumableMedia (as opposed to Media).
  3651. func (c *UsersMessagesInsertCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesInsertCall {
  3652. c.progressUpdater_ = pu
  3653. return c
  3654. }
  3655. // Fields allows partial responses to be retrieved. See
  3656. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3657. // for more information.
  3658. func (c *UsersMessagesInsertCall) Fields(s ...googleapi.Field) *UsersMessagesInsertCall {
  3659. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3660. return c
  3661. }
  3662. // Context sets the context to be used in this call's Do method. Any
  3663. // pending HTTP request will be aborted if the provided context is
  3664. // canceled.
  3665. // This context will supersede any context previously provided to the
  3666. // ResumableMedia method.
  3667. func (c *UsersMessagesInsertCall) Context(ctx context.Context) *UsersMessagesInsertCall {
  3668. c.ctx_ = ctx
  3669. return c
  3670. }
  3671. func (c *UsersMessagesInsertCall) doRequest(alt string) (*http.Response, error) {
  3672. var body io.Reader = nil
  3673. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  3674. if err != nil {
  3675. return nil, err
  3676. }
  3677. ctype := "application/json"
  3678. c.urlParams_.Set("alt", alt)
  3679. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
  3680. if c.media_ != nil || c.resumableBuffer_ != nil {
  3681. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  3682. protocol := "multipart"
  3683. if c.resumableBuffer_ != nil {
  3684. protocol = "resumable"
  3685. }
  3686. c.urlParams_.Set("uploadType", protocol)
  3687. }
  3688. urls += "?" + c.urlParams_.Encode()
  3689. if c.media_ != nil {
  3690. var combined io.ReadCloser
  3691. combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)
  3692. defer combined.Close()
  3693. body = combined
  3694. }
  3695. req, _ := http.NewRequest("POST", urls, body)
  3696. googleapi.Expand(req.URL, map[string]string{
  3697. "userId": c.userId,
  3698. })
  3699. if c.resumableBuffer_ != nil {
  3700. req.Header.Set("X-Upload-Content-Type", c.mediaType_)
  3701. }
  3702. req.Header.Set("Content-Type", ctype)
  3703. req.Header.Set("User-Agent", c.s.userAgent())
  3704. if c.ctx_ != nil {
  3705. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3706. }
  3707. return c.s.client.Do(req)
  3708. }
  3709. // Do executes the "gmail.users.messages.insert" call.
  3710. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  3711. // code is an error. Response headers are in either
  3712. // *Message.ServerResponse.Header or (if a response was returned at all)
  3713. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3714. // check whether the returned error was because http.StatusNotModified
  3715. // was returned.
  3716. func (c *UsersMessagesInsertCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  3717. gensupport.SetOptions(c.urlParams_, opts...)
  3718. res, err := gensupport.Retry(c.ctx_, func() (*http.Response, error) {
  3719. return c.doRequest("json")
  3720. }, gensupport.DefaultBackoffStrategy())
  3721. if res != nil && res.StatusCode == http.StatusNotModified {
  3722. if res.Body != nil {
  3723. res.Body.Close()
  3724. }
  3725. return nil, &googleapi.Error{
  3726. Code: res.StatusCode,
  3727. Header: res.Header,
  3728. }
  3729. }
  3730. if err != nil {
  3731. return nil, err
  3732. }
  3733. defer googleapi.CloseBody(res)
  3734. if err := googleapi.CheckResponse(res); err != nil {
  3735. return nil, err
  3736. }
  3737. if c.resumableBuffer_ != nil {
  3738. loc := res.Header.Get("Location")
  3739. rx := &gensupport.ResumableUpload{
  3740. Client: c.s.client,
  3741. UserAgent: c.s.userAgent(),
  3742. URI: loc,
  3743. Media: c.resumableBuffer_,
  3744. MediaType: c.mediaType_,
  3745. Callback: func(curr int64) {
  3746. if c.progressUpdater_ != nil {
  3747. c.progressUpdater_(curr, c.mediaSize_)
  3748. }
  3749. },
  3750. }
  3751. ctx := c.ctx_
  3752. if ctx == nil {
  3753. ctx = context.TODO()
  3754. }
  3755. res, err = rx.Upload(ctx)
  3756. if err != nil {
  3757. return nil, err
  3758. }
  3759. defer res.Body.Close()
  3760. if err := googleapi.CheckResponse(res); err != nil {
  3761. return nil, err
  3762. }
  3763. }
  3764. ret := &Message{
  3765. ServerResponse: googleapi.ServerResponse{
  3766. Header: res.Header,
  3767. HTTPStatusCode: res.StatusCode,
  3768. },
  3769. }
  3770. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3771. return nil, err
  3772. }
  3773. return ret, nil
  3774. // {
  3775. // "description": "Directly inserts a message into only this user's mailbox similar to IMAP APPEND, bypassing most scanning and classification. Does not send a message.",
  3776. // "httpMethod": "POST",
  3777. // "id": "gmail.users.messages.insert",
  3778. // "mediaUpload": {
  3779. // "accept": [
  3780. // "message/rfc822"
  3781. // ],
  3782. // "maxSize": "35MB",
  3783. // "protocols": {
  3784. // "resumable": {
  3785. // "multipart": true,
  3786. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages"
  3787. // },
  3788. // "simple": {
  3789. // "multipart": true,
  3790. // "path": "/upload/gmail/v1/users/{userId}/messages"
  3791. // }
  3792. // }
  3793. // },
  3794. // "parameterOrder": [
  3795. // "userId"
  3796. // ],
  3797. // "parameters": {
  3798. // "deleted": {
  3799. // "default": "false",
  3800. // "description": "Mark the email as permanently deleted (not TRASH) and only visible in Google Apps Vault to a Vault administrator. Only used for Google Apps for Work accounts.",
  3801. // "location": "query",
  3802. // "type": "boolean"
  3803. // },
  3804. // "internalDateSource": {
  3805. // "default": "receivedTime",
  3806. // "description": "Source for Gmail's internal date of the message.",
  3807. // "enum": [
  3808. // "dateHeader",
  3809. // "receivedTime"
  3810. // ],
  3811. // "enumDescriptions": [
  3812. // "",
  3813. // ""
  3814. // ],
  3815. // "location": "query",
  3816. // "type": "string"
  3817. // },
  3818. // "userId": {
  3819. // "default": "me",
  3820. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  3821. // "location": "path",
  3822. // "required": true,
  3823. // "type": "string"
  3824. // }
  3825. // },
  3826. // "path": "{userId}/messages",
  3827. // "request": {
  3828. // "$ref": "Message"
  3829. // },
  3830. // "response": {
  3831. // "$ref": "Message"
  3832. // },
  3833. // "scopes": [
  3834. // "https://mail.google.com/",
  3835. // "https://www.googleapis.com/auth/gmail.insert",
  3836. // "https://www.googleapis.com/auth/gmail.modify"
  3837. // ],
  3838. // "supportsMediaUpload": true
  3839. // }
  3840. }
  3841. // method id "gmail.users.messages.list":
  3842. type UsersMessagesListCall struct {
  3843. s *Service
  3844. userId string
  3845. urlParams_ gensupport.URLParams
  3846. ifNoneMatch_ string
  3847. ctx_ context.Context
  3848. }
  3849. // List: Lists the messages in the user's mailbox.
  3850. func (r *UsersMessagesService) List(userId string) *UsersMessagesListCall {
  3851. c := &UsersMessagesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3852. c.userId = userId
  3853. return c
  3854. }
  3855. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  3856. // Include messages from SPAM and TRASH in the results.
  3857. func (c *UsersMessagesListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersMessagesListCall {
  3858. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  3859. return c
  3860. }
  3861. // LabelIds sets the optional parameter "labelIds": Only return messages
  3862. // with labels that match all of the specified label IDs.
  3863. func (c *UsersMessagesListCall) LabelIds(labelIds ...string) *UsersMessagesListCall {
  3864. c.urlParams_.SetMulti("labelIds", append([]string{}, labelIds...))
  3865. return c
  3866. }
  3867. // MaxResults sets the optional parameter "maxResults": Maximum number
  3868. // of messages to return.
  3869. func (c *UsersMessagesListCall) MaxResults(maxResults int64) *UsersMessagesListCall {
  3870. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  3871. return c
  3872. }
  3873. // PageToken sets the optional parameter "pageToken": Page token to
  3874. // retrieve a specific page of results in the list.
  3875. func (c *UsersMessagesListCall) PageToken(pageToken string) *UsersMessagesListCall {
  3876. c.urlParams_.Set("pageToken", pageToken)
  3877. return c
  3878. }
  3879. // Q sets the optional parameter "q": Only return messages matching the
  3880. // specified query. Supports the same query format as the Gmail search
  3881. // box. For example, "from:someuser@example.com rfc822msgid: is:unread".
  3882. func (c *UsersMessagesListCall) Q(q string) *UsersMessagesListCall {
  3883. c.urlParams_.Set("q", q)
  3884. return c
  3885. }
  3886. // Fields allows partial responses to be retrieved. See
  3887. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3888. // for more information.
  3889. func (c *UsersMessagesListCall) Fields(s ...googleapi.Field) *UsersMessagesListCall {
  3890. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3891. return c
  3892. }
  3893. // IfNoneMatch sets the optional parameter which makes the operation
  3894. // fail if the object's ETag matches the given value. This is useful for
  3895. // getting updates only after the object has changed since the last
  3896. // request. Use googleapi.IsNotModified to check whether the response
  3897. // error from Do is the result of In-None-Match.
  3898. func (c *UsersMessagesListCall) IfNoneMatch(entityTag string) *UsersMessagesListCall {
  3899. c.ifNoneMatch_ = entityTag
  3900. return c
  3901. }
  3902. // Context sets the context to be used in this call's Do method. Any
  3903. // pending HTTP request will be aborted if the provided context is
  3904. // canceled.
  3905. func (c *UsersMessagesListCall) Context(ctx context.Context) *UsersMessagesListCall {
  3906. c.ctx_ = ctx
  3907. return c
  3908. }
  3909. func (c *UsersMessagesListCall) doRequest(alt string) (*http.Response, error) {
  3910. var body io.Reader = nil
  3911. c.urlParams_.Set("alt", alt)
  3912. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages")
  3913. urls += "?" + c.urlParams_.Encode()
  3914. req, _ := http.NewRequest("GET", urls, body)
  3915. googleapi.Expand(req.URL, map[string]string{
  3916. "userId": c.userId,
  3917. })
  3918. req.Header.Set("User-Agent", c.s.userAgent())
  3919. if c.ifNoneMatch_ != "" {
  3920. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  3921. }
  3922. if c.ctx_ != nil {
  3923. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3924. }
  3925. return c.s.client.Do(req)
  3926. }
  3927. // Do executes the "gmail.users.messages.list" call.
  3928. // Exactly one of *ListMessagesResponse or error will be non-nil. Any
  3929. // non-2xx status code is an error. Response headers are in either
  3930. // *ListMessagesResponse.ServerResponse.Header or (if a response was
  3931. // returned at all) in error.(*googleapi.Error).Header. Use
  3932. // googleapi.IsNotModified to check whether the returned error was
  3933. // because http.StatusNotModified was returned.
  3934. func (c *UsersMessagesListCall) Do(opts ...googleapi.CallOption) (*ListMessagesResponse, error) {
  3935. gensupport.SetOptions(c.urlParams_, opts...)
  3936. res, err := c.doRequest("json")
  3937. if res != nil && res.StatusCode == http.StatusNotModified {
  3938. if res.Body != nil {
  3939. res.Body.Close()
  3940. }
  3941. return nil, &googleapi.Error{
  3942. Code: res.StatusCode,
  3943. Header: res.Header,
  3944. }
  3945. }
  3946. if err != nil {
  3947. return nil, err
  3948. }
  3949. defer googleapi.CloseBody(res)
  3950. if err := googleapi.CheckResponse(res); err != nil {
  3951. return nil, err
  3952. }
  3953. ret := &ListMessagesResponse{
  3954. ServerResponse: googleapi.ServerResponse{
  3955. Header: res.Header,
  3956. HTTPStatusCode: res.StatusCode,
  3957. },
  3958. }
  3959. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3960. return nil, err
  3961. }
  3962. return ret, nil
  3963. // {
  3964. // "description": "Lists the messages in the user's mailbox.",
  3965. // "httpMethod": "GET",
  3966. // "id": "gmail.users.messages.list",
  3967. // "parameterOrder": [
  3968. // "userId"
  3969. // ],
  3970. // "parameters": {
  3971. // "includeSpamTrash": {
  3972. // "default": "false",
  3973. // "description": "Include messages from SPAM and TRASH in the results.",
  3974. // "location": "query",
  3975. // "type": "boolean"
  3976. // },
  3977. // "labelIds": {
  3978. // "description": "Only return messages with labels that match all of the specified label IDs.",
  3979. // "location": "query",
  3980. // "repeated": true,
  3981. // "type": "string"
  3982. // },
  3983. // "maxResults": {
  3984. // "default": "100",
  3985. // "description": "Maximum number of messages to return.",
  3986. // "format": "uint32",
  3987. // "location": "query",
  3988. // "type": "integer"
  3989. // },
  3990. // "pageToken": {
  3991. // "description": "Page token to retrieve a specific page of results in the list.",
  3992. // "location": "query",
  3993. // "type": "string"
  3994. // },
  3995. // "q": {
  3996. // "description": "Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, \"from:someuser@example.com rfc822msgid: is:unread\".",
  3997. // "location": "query",
  3998. // "type": "string"
  3999. // },
  4000. // "userId": {
  4001. // "default": "me",
  4002. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4003. // "location": "path",
  4004. // "required": true,
  4005. // "type": "string"
  4006. // }
  4007. // },
  4008. // "path": "{userId}/messages",
  4009. // "response": {
  4010. // "$ref": "ListMessagesResponse"
  4011. // },
  4012. // "scopes": [
  4013. // "https://mail.google.com/",
  4014. // "https://www.googleapis.com/auth/gmail.modify",
  4015. // "https://www.googleapis.com/auth/gmail.readonly"
  4016. // ]
  4017. // }
  4018. }
  4019. // Pages invokes f for each page of results.
  4020. // A non-nil error returned from f will halt the iteration.
  4021. // The provided context supersedes any context provided to the Context method.
  4022. func (c *UsersMessagesListCall) Pages(ctx context.Context, f func(*ListMessagesResponse) error) error {
  4023. c.ctx_ = ctx
  4024. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  4025. for {
  4026. x, err := c.Do()
  4027. if err != nil {
  4028. return err
  4029. }
  4030. if err := f(x); err != nil {
  4031. return err
  4032. }
  4033. if x.NextPageToken == "" {
  4034. return nil
  4035. }
  4036. c.PageToken(x.NextPageToken)
  4037. }
  4038. }
  4039. // method id "gmail.users.messages.modify":
  4040. type UsersMessagesModifyCall struct {
  4041. s *Service
  4042. userId string
  4043. id string
  4044. modifymessagerequest *ModifyMessageRequest
  4045. urlParams_ gensupport.URLParams
  4046. ctx_ context.Context
  4047. }
  4048. // Modify: Modifies the labels on the specified message.
  4049. func (r *UsersMessagesService) Modify(userId string, id string, modifymessagerequest *ModifyMessageRequest) *UsersMessagesModifyCall {
  4050. c := &UsersMessagesModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4051. c.userId = userId
  4052. c.id = id
  4053. c.modifymessagerequest = modifymessagerequest
  4054. return c
  4055. }
  4056. // Fields allows partial responses to be retrieved. See
  4057. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4058. // for more information.
  4059. func (c *UsersMessagesModifyCall) Fields(s ...googleapi.Field) *UsersMessagesModifyCall {
  4060. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4061. return c
  4062. }
  4063. // Context sets the context to be used in this call's Do method. Any
  4064. // pending HTTP request will be aborted if the provided context is
  4065. // canceled.
  4066. func (c *UsersMessagesModifyCall) Context(ctx context.Context) *UsersMessagesModifyCall {
  4067. c.ctx_ = ctx
  4068. return c
  4069. }
  4070. func (c *UsersMessagesModifyCall) doRequest(alt string) (*http.Response, error) {
  4071. var body io.Reader = nil
  4072. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifymessagerequest)
  4073. if err != nil {
  4074. return nil, err
  4075. }
  4076. ctype := "application/json"
  4077. c.urlParams_.Set("alt", alt)
  4078. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/modify")
  4079. urls += "?" + c.urlParams_.Encode()
  4080. req, _ := http.NewRequest("POST", urls, body)
  4081. googleapi.Expand(req.URL, map[string]string{
  4082. "userId": c.userId,
  4083. "id": c.id,
  4084. })
  4085. req.Header.Set("Content-Type", ctype)
  4086. req.Header.Set("User-Agent", c.s.userAgent())
  4087. if c.ctx_ != nil {
  4088. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4089. }
  4090. return c.s.client.Do(req)
  4091. }
  4092. // Do executes the "gmail.users.messages.modify" call.
  4093. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4094. // code is an error. Response headers are in either
  4095. // *Message.ServerResponse.Header or (if a response was returned at all)
  4096. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4097. // check whether the returned error was because http.StatusNotModified
  4098. // was returned.
  4099. func (c *UsersMessagesModifyCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4100. gensupport.SetOptions(c.urlParams_, opts...)
  4101. res, err := c.doRequest("json")
  4102. if res != nil && res.StatusCode == http.StatusNotModified {
  4103. if res.Body != nil {
  4104. res.Body.Close()
  4105. }
  4106. return nil, &googleapi.Error{
  4107. Code: res.StatusCode,
  4108. Header: res.Header,
  4109. }
  4110. }
  4111. if err != nil {
  4112. return nil, err
  4113. }
  4114. defer googleapi.CloseBody(res)
  4115. if err := googleapi.CheckResponse(res); err != nil {
  4116. return nil, err
  4117. }
  4118. ret := &Message{
  4119. ServerResponse: googleapi.ServerResponse{
  4120. Header: res.Header,
  4121. HTTPStatusCode: res.StatusCode,
  4122. },
  4123. }
  4124. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  4125. return nil, err
  4126. }
  4127. return ret, nil
  4128. // {
  4129. // "description": "Modifies the labels on the specified message.",
  4130. // "httpMethod": "POST",
  4131. // "id": "gmail.users.messages.modify",
  4132. // "parameterOrder": [
  4133. // "userId",
  4134. // "id"
  4135. // ],
  4136. // "parameters": {
  4137. // "id": {
  4138. // "description": "The ID of the message to modify.",
  4139. // "location": "path",
  4140. // "required": true,
  4141. // "type": "string"
  4142. // },
  4143. // "userId": {
  4144. // "default": "me",
  4145. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4146. // "location": "path",
  4147. // "required": true,
  4148. // "type": "string"
  4149. // }
  4150. // },
  4151. // "path": "{userId}/messages/{id}/modify",
  4152. // "request": {
  4153. // "$ref": "ModifyMessageRequest"
  4154. // },
  4155. // "response": {
  4156. // "$ref": "Message"
  4157. // },
  4158. // "scopes": [
  4159. // "https://mail.google.com/",
  4160. // "https://www.googleapis.com/auth/gmail.modify"
  4161. // ]
  4162. // }
  4163. }
  4164. // method id "gmail.users.messages.send":
  4165. type UsersMessagesSendCall struct {
  4166. s *Service
  4167. userId string
  4168. message *Message
  4169. urlParams_ gensupport.URLParams
  4170. media_ io.Reader
  4171. resumableBuffer_ *gensupport.ResumableBuffer
  4172. mediaType_ string
  4173. mediaSize_ int64 // mediaSize, if known. Used only for calls to progressUpdater_.
  4174. progressUpdater_ googleapi.ProgressUpdater
  4175. ctx_ context.Context
  4176. }
  4177. // Send: Sends the specified message to the recipients in the To, Cc,
  4178. // and Bcc headers.
  4179. func (r *UsersMessagesService) Send(userId string, message *Message) *UsersMessagesSendCall {
  4180. c := &UsersMessagesSendCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4181. c.userId = userId
  4182. c.message = message
  4183. return c
  4184. }
  4185. // Media specifies the media to upload in one or more chunks. The chunk
  4186. // size may be controlled by supplying a MediaOption generated by
  4187. // googleapi.ChunkSize. The chunk size defaults to
  4188. // googleapi.DefaultUploadChunkSize.
  4189. // At most one of Media and ResumableMedia may be set.
  4190. func (c *UsersMessagesSendCall) Media(r io.Reader, options ...googleapi.MediaOption) *UsersMessagesSendCall {
  4191. opts := googleapi.ProcessMediaOptions(options)
  4192. chunkSize := opts.ChunkSize
  4193. r, c.mediaType_ = gensupport.DetermineContentType(r, opts.ContentType)
  4194. c.media_, c.resumableBuffer_ = gensupport.PrepareUpload(r, chunkSize)
  4195. return c
  4196. }
  4197. // ResumableMedia specifies the media to upload in chunks and can be
  4198. // canceled with ctx.
  4199. //
  4200. // Deprecated: use Media instead.
  4201. //
  4202. // At most one of Media and ResumableMedia may be set. mediaType
  4203. // identifies the MIME media type of the upload, such as "image/png". If
  4204. // mediaType is "", it will be auto-detected. The provided ctx will
  4205. // supersede any context previously provided to the Context method.
  4206. func (c *UsersMessagesSendCall) ResumableMedia(ctx context.Context, r io.ReaderAt, size int64, mediaType string) *UsersMessagesSendCall {
  4207. c.ctx_ = ctx
  4208. rdr := gensupport.ReaderAtToReader(r, size)
  4209. rdr, c.mediaType_ = gensupport.DetermineContentType(rdr, mediaType)
  4210. c.resumableBuffer_ = gensupport.NewResumableBuffer(rdr, googleapi.DefaultUploadChunkSize)
  4211. c.media_ = nil
  4212. c.mediaSize_ = size
  4213. return c
  4214. }
  4215. // ProgressUpdater provides a callback function that will be called
  4216. // after every chunk. It should be a low-latency function in order to
  4217. // not slow down the upload operation. This should only be called when
  4218. // using ResumableMedia (as opposed to Media).
  4219. func (c *UsersMessagesSendCall) ProgressUpdater(pu googleapi.ProgressUpdater) *UsersMessagesSendCall {
  4220. c.progressUpdater_ = pu
  4221. return c
  4222. }
  4223. // Fields allows partial responses to be retrieved. See
  4224. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4225. // for more information.
  4226. func (c *UsersMessagesSendCall) Fields(s ...googleapi.Field) *UsersMessagesSendCall {
  4227. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4228. return c
  4229. }
  4230. // Context sets the context to be used in this call's Do method. Any
  4231. // pending HTTP request will be aborted if the provided context is
  4232. // canceled.
  4233. // This context will supersede any context previously provided to the
  4234. // ResumableMedia method.
  4235. func (c *UsersMessagesSendCall) Context(ctx context.Context) *UsersMessagesSendCall {
  4236. c.ctx_ = ctx
  4237. return c
  4238. }
  4239. func (c *UsersMessagesSendCall) doRequest(alt string) (*http.Response, error) {
  4240. var body io.Reader = nil
  4241. body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
  4242. if err != nil {
  4243. return nil, err
  4244. }
  4245. ctype := "application/json"
  4246. c.urlParams_.Set("alt", alt)
  4247. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/send")
  4248. if c.media_ != nil || c.resumableBuffer_ != nil {
  4249. urls = strings.Replace(urls, "https://www.googleapis.com/", "https://www.googleapis.com/upload/", 1)
  4250. protocol := "multipart"
  4251. if c.resumableBuffer_ != nil {
  4252. protocol = "resumable"
  4253. }
  4254. c.urlParams_.Set("uploadType", protocol)
  4255. }
  4256. urls += "?" + c.urlParams_.Encode()
  4257. if c.media_ != nil {
  4258. var combined io.ReadCloser
  4259. combined, ctype = gensupport.CombineBodyMedia(body, ctype, c.media_, c.mediaType_)
  4260. defer combined.Close()
  4261. body = combined
  4262. }
  4263. req, _ := http.NewRequest("POST", urls, body)
  4264. googleapi.Expand(req.URL, map[string]string{
  4265. "userId": c.userId,
  4266. })
  4267. if c.resumableBuffer_ != nil {
  4268. req.Header.Set("X-Upload-Content-Type", c.mediaType_)
  4269. }
  4270. req.Header.Set("Content-Type", ctype)
  4271. req.Header.Set("User-Agent", c.s.userAgent())
  4272. if c.ctx_ != nil {
  4273. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4274. }
  4275. return c.s.client.Do(req)
  4276. }
  4277. // Do executes the "gmail.users.messages.send" call.
  4278. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4279. // code is an error. Response headers are in either
  4280. // *Message.ServerResponse.Header or (if a response was returned at all)
  4281. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4282. // check whether the returned error was because http.StatusNotModified
  4283. // was returned.
  4284. func (c *UsersMessagesSendCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4285. gensupport.SetOptions(c.urlParams_, opts...)
  4286. res, err := gensupport.Retry(c.ctx_, func() (*http.Response, error) {
  4287. return c.doRequest("json")
  4288. }, gensupport.DefaultBackoffStrategy())
  4289. if res != nil && res.StatusCode == http.StatusNotModified {
  4290. if res.Body != nil {
  4291. res.Body.Close()
  4292. }
  4293. return nil, &googleapi.Error{
  4294. Code: res.StatusCode,
  4295. Header: res.Header,
  4296. }
  4297. }
  4298. if err != nil {
  4299. return nil, err
  4300. }
  4301. defer googleapi.CloseBody(res)
  4302. if err := googleapi.CheckResponse(res); err != nil {
  4303. return nil, err
  4304. }
  4305. if c.resumableBuffer_ != nil {
  4306. loc := res.Header.Get("Location")
  4307. rx := &gensupport.ResumableUpload{
  4308. Client: c.s.client,
  4309. UserAgent: c.s.userAgent(),
  4310. URI: loc,
  4311. Media: c.resumableBuffer_,
  4312. MediaType: c.mediaType_,
  4313. Callback: func(curr int64) {
  4314. if c.progressUpdater_ != nil {
  4315. c.progressUpdater_(curr, c.mediaSize_)
  4316. }
  4317. },
  4318. }
  4319. ctx := c.ctx_
  4320. if ctx == nil {
  4321. ctx = context.TODO()
  4322. }
  4323. res, err = rx.Upload(ctx)
  4324. if err != nil {
  4325. return nil, err
  4326. }
  4327. defer res.Body.Close()
  4328. if err := googleapi.CheckResponse(res); err != nil {
  4329. return nil, err
  4330. }
  4331. }
  4332. ret := &Message{
  4333. ServerResponse: googleapi.ServerResponse{
  4334. Header: res.Header,
  4335. HTTPStatusCode: res.StatusCode,
  4336. },
  4337. }
  4338. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  4339. return nil, err
  4340. }
  4341. return ret, nil
  4342. // {
  4343. // "description": "Sends the specified message to the recipients in the To, Cc, and Bcc headers.",
  4344. // "httpMethod": "POST",
  4345. // "id": "gmail.users.messages.send",
  4346. // "mediaUpload": {
  4347. // "accept": [
  4348. // "message/rfc822"
  4349. // ],
  4350. // "maxSize": "35MB",
  4351. // "protocols": {
  4352. // "resumable": {
  4353. // "multipart": true,
  4354. // "path": "/resumable/upload/gmail/v1/users/{userId}/messages/send"
  4355. // },
  4356. // "simple": {
  4357. // "multipart": true,
  4358. // "path": "/upload/gmail/v1/users/{userId}/messages/send"
  4359. // }
  4360. // }
  4361. // },
  4362. // "parameterOrder": [
  4363. // "userId"
  4364. // ],
  4365. // "parameters": {
  4366. // "userId": {
  4367. // "default": "me",
  4368. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4369. // "location": "path",
  4370. // "required": true,
  4371. // "type": "string"
  4372. // }
  4373. // },
  4374. // "path": "{userId}/messages/send",
  4375. // "request": {
  4376. // "$ref": "Message"
  4377. // },
  4378. // "response": {
  4379. // "$ref": "Message"
  4380. // },
  4381. // "scopes": [
  4382. // "https://mail.google.com/",
  4383. // "https://www.googleapis.com/auth/gmail.compose",
  4384. // "https://www.googleapis.com/auth/gmail.modify",
  4385. // "https://www.googleapis.com/auth/gmail.send"
  4386. // ],
  4387. // "supportsMediaUpload": true
  4388. // }
  4389. }
  4390. // method id "gmail.users.messages.trash":
  4391. type UsersMessagesTrashCall struct {
  4392. s *Service
  4393. userId string
  4394. id string
  4395. urlParams_ gensupport.URLParams
  4396. ctx_ context.Context
  4397. }
  4398. // Trash: Moves the specified message to the trash.
  4399. func (r *UsersMessagesService) Trash(userId string, id string) *UsersMessagesTrashCall {
  4400. c := &UsersMessagesTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4401. c.userId = userId
  4402. c.id = id
  4403. return c
  4404. }
  4405. // Fields allows partial responses to be retrieved. See
  4406. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4407. // for more information.
  4408. func (c *UsersMessagesTrashCall) Fields(s ...googleapi.Field) *UsersMessagesTrashCall {
  4409. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4410. return c
  4411. }
  4412. // Context sets the context to be used in this call's Do method. Any
  4413. // pending HTTP request will be aborted if the provided context is
  4414. // canceled.
  4415. func (c *UsersMessagesTrashCall) Context(ctx context.Context) *UsersMessagesTrashCall {
  4416. c.ctx_ = ctx
  4417. return c
  4418. }
  4419. func (c *UsersMessagesTrashCall) doRequest(alt string) (*http.Response, error) {
  4420. var body io.Reader = nil
  4421. c.urlParams_.Set("alt", alt)
  4422. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/trash")
  4423. urls += "?" + c.urlParams_.Encode()
  4424. req, _ := http.NewRequest("POST", urls, body)
  4425. googleapi.Expand(req.URL, map[string]string{
  4426. "userId": c.userId,
  4427. "id": c.id,
  4428. })
  4429. req.Header.Set("User-Agent", c.s.userAgent())
  4430. if c.ctx_ != nil {
  4431. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4432. }
  4433. return c.s.client.Do(req)
  4434. }
  4435. // Do executes the "gmail.users.messages.trash" call.
  4436. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4437. // code is an error. Response headers are in either
  4438. // *Message.ServerResponse.Header or (if a response was returned at all)
  4439. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4440. // check whether the returned error was because http.StatusNotModified
  4441. // was returned.
  4442. func (c *UsersMessagesTrashCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4443. gensupport.SetOptions(c.urlParams_, opts...)
  4444. res, err := c.doRequest("json")
  4445. if res != nil && res.StatusCode == http.StatusNotModified {
  4446. if res.Body != nil {
  4447. res.Body.Close()
  4448. }
  4449. return nil, &googleapi.Error{
  4450. Code: res.StatusCode,
  4451. Header: res.Header,
  4452. }
  4453. }
  4454. if err != nil {
  4455. return nil, err
  4456. }
  4457. defer googleapi.CloseBody(res)
  4458. if err := googleapi.CheckResponse(res); err != nil {
  4459. return nil, err
  4460. }
  4461. ret := &Message{
  4462. ServerResponse: googleapi.ServerResponse{
  4463. Header: res.Header,
  4464. HTTPStatusCode: res.StatusCode,
  4465. },
  4466. }
  4467. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  4468. return nil, err
  4469. }
  4470. return ret, nil
  4471. // {
  4472. // "description": "Moves the specified message to the trash.",
  4473. // "httpMethod": "POST",
  4474. // "id": "gmail.users.messages.trash",
  4475. // "parameterOrder": [
  4476. // "userId",
  4477. // "id"
  4478. // ],
  4479. // "parameters": {
  4480. // "id": {
  4481. // "description": "The ID of the message to Trash.",
  4482. // "location": "path",
  4483. // "required": true,
  4484. // "type": "string"
  4485. // },
  4486. // "userId": {
  4487. // "default": "me",
  4488. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4489. // "location": "path",
  4490. // "required": true,
  4491. // "type": "string"
  4492. // }
  4493. // },
  4494. // "path": "{userId}/messages/{id}/trash",
  4495. // "response": {
  4496. // "$ref": "Message"
  4497. // },
  4498. // "scopes": [
  4499. // "https://mail.google.com/",
  4500. // "https://www.googleapis.com/auth/gmail.modify"
  4501. // ]
  4502. // }
  4503. }
  4504. // method id "gmail.users.messages.untrash":
  4505. type UsersMessagesUntrashCall struct {
  4506. s *Service
  4507. userId string
  4508. id string
  4509. urlParams_ gensupport.URLParams
  4510. ctx_ context.Context
  4511. }
  4512. // Untrash: Removes the specified message from the trash.
  4513. func (r *UsersMessagesService) Untrash(userId string, id string) *UsersMessagesUntrashCall {
  4514. c := &UsersMessagesUntrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4515. c.userId = userId
  4516. c.id = id
  4517. return c
  4518. }
  4519. // Fields allows partial responses to be retrieved. See
  4520. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4521. // for more information.
  4522. func (c *UsersMessagesUntrashCall) Fields(s ...googleapi.Field) *UsersMessagesUntrashCall {
  4523. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4524. return c
  4525. }
  4526. // Context sets the context to be used in this call's Do method. Any
  4527. // pending HTTP request will be aborted if the provided context is
  4528. // canceled.
  4529. func (c *UsersMessagesUntrashCall) Context(ctx context.Context) *UsersMessagesUntrashCall {
  4530. c.ctx_ = ctx
  4531. return c
  4532. }
  4533. func (c *UsersMessagesUntrashCall) doRequest(alt string) (*http.Response, error) {
  4534. var body io.Reader = nil
  4535. c.urlParams_.Set("alt", alt)
  4536. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{id}/untrash")
  4537. urls += "?" + c.urlParams_.Encode()
  4538. req, _ := http.NewRequest("POST", urls, body)
  4539. googleapi.Expand(req.URL, map[string]string{
  4540. "userId": c.userId,
  4541. "id": c.id,
  4542. })
  4543. req.Header.Set("User-Agent", c.s.userAgent())
  4544. if c.ctx_ != nil {
  4545. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4546. }
  4547. return c.s.client.Do(req)
  4548. }
  4549. // Do executes the "gmail.users.messages.untrash" call.
  4550. // Exactly one of *Message or error will be non-nil. Any non-2xx status
  4551. // code is an error. Response headers are in either
  4552. // *Message.ServerResponse.Header or (if a response was returned at all)
  4553. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4554. // check whether the returned error was because http.StatusNotModified
  4555. // was returned.
  4556. func (c *UsersMessagesUntrashCall) Do(opts ...googleapi.CallOption) (*Message, error) {
  4557. gensupport.SetOptions(c.urlParams_, opts...)
  4558. res, err := c.doRequest("json")
  4559. if res != nil && res.StatusCode == http.StatusNotModified {
  4560. if res.Body != nil {
  4561. res.Body.Close()
  4562. }
  4563. return nil, &googleapi.Error{
  4564. Code: res.StatusCode,
  4565. Header: res.Header,
  4566. }
  4567. }
  4568. if err != nil {
  4569. return nil, err
  4570. }
  4571. defer googleapi.CloseBody(res)
  4572. if err := googleapi.CheckResponse(res); err != nil {
  4573. return nil, err
  4574. }
  4575. ret := &Message{
  4576. ServerResponse: googleapi.ServerResponse{
  4577. Header: res.Header,
  4578. HTTPStatusCode: res.StatusCode,
  4579. },
  4580. }
  4581. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  4582. return nil, err
  4583. }
  4584. return ret, nil
  4585. // {
  4586. // "description": "Removes the specified message from the trash.",
  4587. // "httpMethod": "POST",
  4588. // "id": "gmail.users.messages.untrash",
  4589. // "parameterOrder": [
  4590. // "userId",
  4591. // "id"
  4592. // ],
  4593. // "parameters": {
  4594. // "id": {
  4595. // "description": "The ID of the message to remove from Trash.",
  4596. // "location": "path",
  4597. // "required": true,
  4598. // "type": "string"
  4599. // },
  4600. // "userId": {
  4601. // "default": "me",
  4602. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4603. // "location": "path",
  4604. // "required": true,
  4605. // "type": "string"
  4606. // }
  4607. // },
  4608. // "path": "{userId}/messages/{id}/untrash",
  4609. // "response": {
  4610. // "$ref": "Message"
  4611. // },
  4612. // "scopes": [
  4613. // "https://mail.google.com/",
  4614. // "https://www.googleapis.com/auth/gmail.modify"
  4615. // ]
  4616. // }
  4617. }
  4618. // method id "gmail.users.messages.attachments.get":
  4619. type UsersMessagesAttachmentsGetCall struct {
  4620. s *Service
  4621. userId string
  4622. messageId string
  4623. id string
  4624. urlParams_ gensupport.URLParams
  4625. ifNoneMatch_ string
  4626. ctx_ context.Context
  4627. }
  4628. // Get: Gets the specified message attachment.
  4629. func (r *UsersMessagesAttachmentsService) Get(userId string, messageId string, id string) *UsersMessagesAttachmentsGetCall {
  4630. c := &UsersMessagesAttachmentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4631. c.userId = userId
  4632. c.messageId = messageId
  4633. c.id = id
  4634. return c
  4635. }
  4636. // Fields allows partial responses to be retrieved. See
  4637. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4638. // for more information.
  4639. func (c *UsersMessagesAttachmentsGetCall) Fields(s ...googleapi.Field) *UsersMessagesAttachmentsGetCall {
  4640. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4641. return c
  4642. }
  4643. // IfNoneMatch sets the optional parameter which makes the operation
  4644. // fail if the object's ETag matches the given value. This is useful for
  4645. // getting updates only after the object has changed since the last
  4646. // request. Use googleapi.IsNotModified to check whether the response
  4647. // error from Do is the result of In-None-Match.
  4648. func (c *UsersMessagesAttachmentsGetCall) IfNoneMatch(entityTag string) *UsersMessagesAttachmentsGetCall {
  4649. c.ifNoneMatch_ = entityTag
  4650. return c
  4651. }
  4652. // Context sets the context to be used in this call's Do method. Any
  4653. // pending HTTP request will be aborted if the provided context is
  4654. // canceled.
  4655. func (c *UsersMessagesAttachmentsGetCall) Context(ctx context.Context) *UsersMessagesAttachmentsGetCall {
  4656. c.ctx_ = ctx
  4657. return c
  4658. }
  4659. func (c *UsersMessagesAttachmentsGetCall) doRequest(alt string) (*http.Response, error) {
  4660. var body io.Reader = nil
  4661. c.urlParams_.Set("alt", alt)
  4662. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/messages/{messageId}/attachments/{id}")
  4663. urls += "?" + c.urlParams_.Encode()
  4664. req, _ := http.NewRequest("GET", urls, body)
  4665. googleapi.Expand(req.URL, map[string]string{
  4666. "userId": c.userId,
  4667. "messageId": c.messageId,
  4668. "id": c.id,
  4669. })
  4670. req.Header.Set("User-Agent", c.s.userAgent())
  4671. if c.ifNoneMatch_ != "" {
  4672. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  4673. }
  4674. if c.ctx_ != nil {
  4675. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4676. }
  4677. return c.s.client.Do(req)
  4678. }
  4679. // Do executes the "gmail.users.messages.attachments.get" call.
  4680. // Exactly one of *MessagePartBody or error will be non-nil. Any non-2xx
  4681. // status code is an error. Response headers are in either
  4682. // *MessagePartBody.ServerResponse.Header or (if a response was returned
  4683. // at all) in error.(*googleapi.Error).Header. Use
  4684. // googleapi.IsNotModified to check whether the returned error was
  4685. // because http.StatusNotModified was returned.
  4686. func (c *UsersMessagesAttachmentsGetCall) Do(opts ...googleapi.CallOption) (*MessagePartBody, error) {
  4687. gensupport.SetOptions(c.urlParams_, opts...)
  4688. res, err := c.doRequest("json")
  4689. if res != nil && res.StatusCode == http.StatusNotModified {
  4690. if res.Body != nil {
  4691. res.Body.Close()
  4692. }
  4693. return nil, &googleapi.Error{
  4694. Code: res.StatusCode,
  4695. Header: res.Header,
  4696. }
  4697. }
  4698. if err != nil {
  4699. return nil, err
  4700. }
  4701. defer googleapi.CloseBody(res)
  4702. if err := googleapi.CheckResponse(res); err != nil {
  4703. return nil, err
  4704. }
  4705. ret := &MessagePartBody{
  4706. ServerResponse: googleapi.ServerResponse{
  4707. Header: res.Header,
  4708. HTTPStatusCode: res.StatusCode,
  4709. },
  4710. }
  4711. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  4712. return nil, err
  4713. }
  4714. return ret, nil
  4715. // {
  4716. // "description": "Gets the specified message attachment.",
  4717. // "httpMethod": "GET",
  4718. // "id": "gmail.users.messages.attachments.get",
  4719. // "parameterOrder": [
  4720. // "userId",
  4721. // "messageId",
  4722. // "id"
  4723. // ],
  4724. // "parameters": {
  4725. // "id": {
  4726. // "description": "The ID of the attachment.",
  4727. // "location": "path",
  4728. // "required": true,
  4729. // "type": "string"
  4730. // },
  4731. // "messageId": {
  4732. // "description": "The ID of the message containing the attachment.",
  4733. // "location": "path",
  4734. // "required": true,
  4735. // "type": "string"
  4736. // },
  4737. // "userId": {
  4738. // "default": "me",
  4739. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4740. // "location": "path",
  4741. // "required": true,
  4742. // "type": "string"
  4743. // }
  4744. // },
  4745. // "path": "{userId}/messages/{messageId}/attachments/{id}",
  4746. // "response": {
  4747. // "$ref": "MessagePartBody"
  4748. // },
  4749. // "scopes": [
  4750. // "https://mail.google.com/",
  4751. // "https://www.googleapis.com/auth/gmail.modify",
  4752. // "https://www.googleapis.com/auth/gmail.readonly"
  4753. // ]
  4754. // }
  4755. }
  4756. // method id "gmail.users.threads.delete":
  4757. type UsersThreadsDeleteCall struct {
  4758. s *Service
  4759. userId string
  4760. id string
  4761. urlParams_ gensupport.URLParams
  4762. ctx_ context.Context
  4763. }
  4764. // Delete: Immediately and permanently deletes the specified thread.
  4765. // This operation cannot be undone. Prefer threads.trash instead.
  4766. func (r *UsersThreadsService) Delete(userId string, id string) *UsersThreadsDeleteCall {
  4767. c := &UsersThreadsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4768. c.userId = userId
  4769. c.id = id
  4770. return c
  4771. }
  4772. // Fields allows partial responses to be retrieved. See
  4773. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4774. // for more information.
  4775. func (c *UsersThreadsDeleteCall) Fields(s ...googleapi.Field) *UsersThreadsDeleteCall {
  4776. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4777. return c
  4778. }
  4779. // Context sets the context to be used in this call's Do method. Any
  4780. // pending HTTP request will be aborted if the provided context is
  4781. // canceled.
  4782. func (c *UsersThreadsDeleteCall) Context(ctx context.Context) *UsersThreadsDeleteCall {
  4783. c.ctx_ = ctx
  4784. return c
  4785. }
  4786. func (c *UsersThreadsDeleteCall) doRequest(alt string) (*http.Response, error) {
  4787. var body io.Reader = nil
  4788. c.urlParams_.Set("alt", alt)
  4789. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
  4790. urls += "?" + c.urlParams_.Encode()
  4791. req, _ := http.NewRequest("DELETE", urls, body)
  4792. googleapi.Expand(req.URL, map[string]string{
  4793. "userId": c.userId,
  4794. "id": c.id,
  4795. })
  4796. req.Header.Set("User-Agent", c.s.userAgent())
  4797. if c.ctx_ != nil {
  4798. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4799. }
  4800. return c.s.client.Do(req)
  4801. }
  4802. // Do executes the "gmail.users.threads.delete" call.
  4803. func (c *UsersThreadsDeleteCall) Do(opts ...googleapi.CallOption) error {
  4804. gensupport.SetOptions(c.urlParams_, opts...)
  4805. res, err := c.doRequest("json")
  4806. if err != nil {
  4807. return err
  4808. }
  4809. defer googleapi.CloseBody(res)
  4810. if err := googleapi.CheckResponse(res); err != nil {
  4811. return err
  4812. }
  4813. return nil
  4814. // {
  4815. // "description": "Immediately and permanently deletes the specified thread. This operation cannot be undone. Prefer threads.trash instead.",
  4816. // "httpMethod": "DELETE",
  4817. // "id": "gmail.users.threads.delete",
  4818. // "parameterOrder": [
  4819. // "userId",
  4820. // "id"
  4821. // ],
  4822. // "parameters": {
  4823. // "id": {
  4824. // "description": "ID of the Thread to delete.",
  4825. // "location": "path",
  4826. // "required": true,
  4827. // "type": "string"
  4828. // },
  4829. // "userId": {
  4830. // "default": "me",
  4831. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4832. // "location": "path",
  4833. // "required": true,
  4834. // "type": "string"
  4835. // }
  4836. // },
  4837. // "path": "{userId}/threads/{id}",
  4838. // "scopes": [
  4839. // "https://mail.google.com/"
  4840. // ]
  4841. // }
  4842. }
  4843. // method id "gmail.users.threads.get":
  4844. type UsersThreadsGetCall struct {
  4845. s *Service
  4846. userId string
  4847. id string
  4848. urlParams_ gensupport.URLParams
  4849. ifNoneMatch_ string
  4850. ctx_ context.Context
  4851. }
  4852. // Get: Gets the specified thread.
  4853. func (r *UsersThreadsService) Get(userId string, id string) *UsersThreadsGetCall {
  4854. c := &UsersThreadsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4855. c.userId = userId
  4856. c.id = id
  4857. return c
  4858. }
  4859. // Format sets the optional parameter "format": The format to return the
  4860. // messages in.
  4861. //
  4862. // Possible values:
  4863. // "full" (default)
  4864. // "metadata"
  4865. // "minimal"
  4866. func (c *UsersThreadsGetCall) Format(format string) *UsersThreadsGetCall {
  4867. c.urlParams_.Set("format", format)
  4868. return c
  4869. }
  4870. // MetadataHeaders sets the optional parameter "metadataHeaders": When
  4871. // given and format is METADATA, only include headers specified.
  4872. func (c *UsersThreadsGetCall) MetadataHeaders(metadataHeaders ...string) *UsersThreadsGetCall {
  4873. c.urlParams_.SetMulti("metadataHeaders", append([]string{}, metadataHeaders...))
  4874. return c
  4875. }
  4876. // Fields allows partial responses to be retrieved. See
  4877. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4878. // for more information.
  4879. func (c *UsersThreadsGetCall) Fields(s ...googleapi.Field) *UsersThreadsGetCall {
  4880. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4881. return c
  4882. }
  4883. // IfNoneMatch sets the optional parameter which makes the operation
  4884. // fail if the object's ETag matches the given value. This is useful for
  4885. // getting updates only after the object has changed since the last
  4886. // request. Use googleapi.IsNotModified to check whether the response
  4887. // error from Do is the result of In-None-Match.
  4888. func (c *UsersThreadsGetCall) IfNoneMatch(entityTag string) *UsersThreadsGetCall {
  4889. c.ifNoneMatch_ = entityTag
  4890. return c
  4891. }
  4892. // Context sets the context to be used in this call's Do method. Any
  4893. // pending HTTP request will be aborted if the provided context is
  4894. // canceled.
  4895. func (c *UsersThreadsGetCall) Context(ctx context.Context) *UsersThreadsGetCall {
  4896. c.ctx_ = ctx
  4897. return c
  4898. }
  4899. func (c *UsersThreadsGetCall) doRequest(alt string) (*http.Response, error) {
  4900. var body io.Reader = nil
  4901. c.urlParams_.Set("alt", alt)
  4902. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}")
  4903. urls += "?" + c.urlParams_.Encode()
  4904. req, _ := http.NewRequest("GET", urls, body)
  4905. googleapi.Expand(req.URL, map[string]string{
  4906. "userId": c.userId,
  4907. "id": c.id,
  4908. })
  4909. req.Header.Set("User-Agent", c.s.userAgent())
  4910. if c.ifNoneMatch_ != "" {
  4911. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  4912. }
  4913. if c.ctx_ != nil {
  4914. return ctxhttp.Do(c.ctx_, c.s.client, req)
  4915. }
  4916. return c.s.client.Do(req)
  4917. }
  4918. // Do executes the "gmail.users.threads.get" call.
  4919. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  4920. // code is an error. Response headers are in either
  4921. // *Thread.ServerResponse.Header or (if a response was returned at all)
  4922. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4923. // check whether the returned error was because http.StatusNotModified
  4924. // was returned.
  4925. func (c *UsersThreadsGetCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  4926. gensupport.SetOptions(c.urlParams_, opts...)
  4927. res, err := c.doRequest("json")
  4928. if res != nil && res.StatusCode == http.StatusNotModified {
  4929. if res.Body != nil {
  4930. res.Body.Close()
  4931. }
  4932. return nil, &googleapi.Error{
  4933. Code: res.StatusCode,
  4934. Header: res.Header,
  4935. }
  4936. }
  4937. if err != nil {
  4938. return nil, err
  4939. }
  4940. defer googleapi.CloseBody(res)
  4941. if err := googleapi.CheckResponse(res); err != nil {
  4942. return nil, err
  4943. }
  4944. ret := &Thread{
  4945. ServerResponse: googleapi.ServerResponse{
  4946. Header: res.Header,
  4947. HTTPStatusCode: res.StatusCode,
  4948. },
  4949. }
  4950. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  4951. return nil, err
  4952. }
  4953. return ret, nil
  4954. // {
  4955. // "description": "Gets the specified thread.",
  4956. // "httpMethod": "GET",
  4957. // "id": "gmail.users.threads.get",
  4958. // "parameterOrder": [
  4959. // "userId",
  4960. // "id"
  4961. // ],
  4962. // "parameters": {
  4963. // "format": {
  4964. // "default": "full",
  4965. // "description": "The format to return the messages in.",
  4966. // "enum": [
  4967. // "full",
  4968. // "metadata",
  4969. // "minimal"
  4970. // ],
  4971. // "enumDescriptions": [
  4972. // "",
  4973. // "",
  4974. // ""
  4975. // ],
  4976. // "location": "query",
  4977. // "type": "string"
  4978. // },
  4979. // "id": {
  4980. // "description": "The ID of the thread to retrieve.",
  4981. // "location": "path",
  4982. // "required": true,
  4983. // "type": "string"
  4984. // },
  4985. // "metadataHeaders": {
  4986. // "description": "When given and format is METADATA, only include headers specified.",
  4987. // "location": "query",
  4988. // "repeated": true,
  4989. // "type": "string"
  4990. // },
  4991. // "userId": {
  4992. // "default": "me",
  4993. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  4994. // "location": "path",
  4995. // "required": true,
  4996. // "type": "string"
  4997. // }
  4998. // },
  4999. // "path": "{userId}/threads/{id}",
  5000. // "response": {
  5001. // "$ref": "Thread"
  5002. // },
  5003. // "scopes": [
  5004. // "https://mail.google.com/",
  5005. // "https://www.googleapis.com/auth/gmail.modify",
  5006. // "https://www.googleapis.com/auth/gmail.readonly"
  5007. // ]
  5008. // }
  5009. }
  5010. // method id "gmail.users.threads.list":
  5011. type UsersThreadsListCall struct {
  5012. s *Service
  5013. userId string
  5014. urlParams_ gensupport.URLParams
  5015. ifNoneMatch_ string
  5016. ctx_ context.Context
  5017. }
  5018. // List: Lists the threads in the user's mailbox.
  5019. func (r *UsersThreadsService) List(userId string) *UsersThreadsListCall {
  5020. c := &UsersThreadsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5021. c.userId = userId
  5022. return c
  5023. }
  5024. // IncludeSpamTrash sets the optional parameter "includeSpamTrash":
  5025. // Include threads from SPAM and TRASH in the results.
  5026. func (c *UsersThreadsListCall) IncludeSpamTrash(includeSpamTrash bool) *UsersThreadsListCall {
  5027. c.urlParams_.Set("includeSpamTrash", fmt.Sprint(includeSpamTrash))
  5028. return c
  5029. }
  5030. // LabelIds sets the optional parameter "labelIds": Only return threads
  5031. // with labels that match all of the specified label IDs.
  5032. func (c *UsersThreadsListCall) LabelIds(labelIds ...string) *UsersThreadsListCall {
  5033. c.urlParams_.SetMulti("labelIds", append([]string{}, labelIds...))
  5034. return c
  5035. }
  5036. // MaxResults sets the optional parameter "maxResults": Maximum number
  5037. // of threads to return.
  5038. func (c *UsersThreadsListCall) MaxResults(maxResults int64) *UsersThreadsListCall {
  5039. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  5040. return c
  5041. }
  5042. // PageToken sets the optional parameter "pageToken": Page token to
  5043. // retrieve a specific page of results in the list.
  5044. func (c *UsersThreadsListCall) PageToken(pageToken string) *UsersThreadsListCall {
  5045. c.urlParams_.Set("pageToken", pageToken)
  5046. return c
  5047. }
  5048. // Q sets the optional parameter "q": Only return threads matching the
  5049. // specified query. Supports the same query format as the Gmail search
  5050. // box. For example, "from:someuser@example.com rfc822msgid: is:unread".
  5051. func (c *UsersThreadsListCall) Q(q string) *UsersThreadsListCall {
  5052. c.urlParams_.Set("q", q)
  5053. return c
  5054. }
  5055. // Fields allows partial responses to be retrieved. See
  5056. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5057. // for more information.
  5058. func (c *UsersThreadsListCall) Fields(s ...googleapi.Field) *UsersThreadsListCall {
  5059. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5060. return c
  5061. }
  5062. // IfNoneMatch sets the optional parameter which makes the operation
  5063. // fail if the object's ETag matches the given value. This is useful for
  5064. // getting updates only after the object has changed since the last
  5065. // request. Use googleapi.IsNotModified to check whether the response
  5066. // error from Do is the result of In-None-Match.
  5067. func (c *UsersThreadsListCall) IfNoneMatch(entityTag string) *UsersThreadsListCall {
  5068. c.ifNoneMatch_ = entityTag
  5069. return c
  5070. }
  5071. // Context sets the context to be used in this call's Do method. Any
  5072. // pending HTTP request will be aborted if the provided context is
  5073. // canceled.
  5074. func (c *UsersThreadsListCall) Context(ctx context.Context) *UsersThreadsListCall {
  5075. c.ctx_ = ctx
  5076. return c
  5077. }
  5078. func (c *UsersThreadsListCall) doRequest(alt string) (*http.Response, error) {
  5079. var body io.Reader = nil
  5080. c.urlParams_.Set("alt", alt)
  5081. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads")
  5082. urls += "?" + c.urlParams_.Encode()
  5083. req, _ := http.NewRequest("GET", urls, body)
  5084. googleapi.Expand(req.URL, map[string]string{
  5085. "userId": c.userId,
  5086. })
  5087. req.Header.Set("User-Agent", c.s.userAgent())
  5088. if c.ifNoneMatch_ != "" {
  5089. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  5090. }
  5091. if c.ctx_ != nil {
  5092. return ctxhttp.Do(c.ctx_, c.s.client, req)
  5093. }
  5094. return c.s.client.Do(req)
  5095. }
  5096. // Do executes the "gmail.users.threads.list" call.
  5097. // Exactly one of *ListThreadsResponse or error will be non-nil. Any
  5098. // non-2xx status code is an error. Response headers are in either
  5099. // *ListThreadsResponse.ServerResponse.Header or (if a response was
  5100. // returned at all) in error.(*googleapi.Error).Header. Use
  5101. // googleapi.IsNotModified to check whether the returned error was
  5102. // because http.StatusNotModified was returned.
  5103. func (c *UsersThreadsListCall) Do(opts ...googleapi.CallOption) (*ListThreadsResponse, error) {
  5104. gensupport.SetOptions(c.urlParams_, opts...)
  5105. res, err := c.doRequest("json")
  5106. if res != nil && res.StatusCode == http.StatusNotModified {
  5107. if res.Body != nil {
  5108. res.Body.Close()
  5109. }
  5110. return nil, &googleapi.Error{
  5111. Code: res.StatusCode,
  5112. Header: res.Header,
  5113. }
  5114. }
  5115. if err != nil {
  5116. return nil, err
  5117. }
  5118. defer googleapi.CloseBody(res)
  5119. if err := googleapi.CheckResponse(res); err != nil {
  5120. return nil, err
  5121. }
  5122. ret := &ListThreadsResponse{
  5123. ServerResponse: googleapi.ServerResponse{
  5124. Header: res.Header,
  5125. HTTPStatusCode: res.StatusCode,
  5126. },
  5127. }
  5128. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  5129. return nil, err
  5130. }
  5131. return ret, nil
  5132. // {
  5133. // "description": "Lists the threads in the user's mailbox.",
  5134. // "httpMethod": "GET",
  5135. // "id": "gmail.users.threads.list",
  5136. // "parameterOrder": [
  5137. // "userId"
  5138. // ],
  5139. // "parameters": {
  5140. // "includeSpamTrash": {
  5141. // "default": "false",
  5142. // "description": "Include threads from SPAM and TRASH in the results.",
  5143. // "location": "query",
  5144. // "type": "boolean"
  5145. // },
  5146. // "labelIds": {
  5147. // "description": "Only return threads with labels that match all of the specified label IDs.",
  5148. // "location": "query",
  5149. // "repeated": true,
  5150. // "type": "string"
  5151. // },
  5152. // "maxResults": {
  5153. // "default": "100",
  5154. // "description": "Maximum number of threads to return.",
  5155. // "format": "uint32",
  5156. // "location": "query",
  5157. // "type": "integer"
  5158. // },
  5159. // "pageToken": {
  5160. // "description": "Page token to retrieve a specific page of results in the list.",
  5161. // "location": "query",
  5162. // "type": "string"
  5163. // },
  5164. // "q": {
  5165. // "description": "Only return threads matching the specified query. Supports the same query format as the Gmail search box. For example, \"from:someuser@example.com rfc822msgid: is:unread\".",
  5166. // "location": "query",
  5167. // "type": "string"
  5168. // },
  5169. // "userId": {
  5170. // "default": "me",
  5171. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5172. // "location": "path",
  5173. // "required": true,
  5174. // "type": "string"
  5175. // }
  5176. // },
  5177. // "path": "{userId}/threads",
  5178. // "response": {
  5179. // "$ref": "ListThreadsResponse"
  5180. // },
  5181. // "scopes": [
  5182. // "https://mail.google.com/",
  5183. // "https://www.googleapis.com/auth/gmail.modify",
  5184. // "https://www.googleapis.com/auth/gmail.readonly"
  5185. // ]
  5186. // }
  5187. }
  5188. // Pages invokes f for each page of results.
  5189. // A non-nil error returned from f will halt the iteration.
  5190. // The provided context supersedes any context provided to the Context method.
  5191. func (c *UsersThreadsListCall) Pages(ctx context.Context, f func(*ListThreadsResponse) error) error {
  5192. c.ctx_ = ctx
  5193. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  5194. for {
  5195. x, err := c.Do()
  5196. if err != nil {
  5197. return err
  5198. }
  5199. if err := f(x); err != nil {
  5200. return err
  5201. }
  5202. if x.NextPageToken == "" {
  5203. return nil
  5204. }
  5205. c.PageToken(x.NextPageToken)
  5206. }
  5207. }
  5208. // method id "gmail.users.threads.modify":
  5209. type UsersThreadsModifyCall struct {
  5210. s *Service
  5211. userId string
  5212. id string
  5213. modifythreadrequest *ModifyThreadRequest
  5214. urlParams_ gensupport.URLParams
  5215. ctx_ context.Context
  5216. }
  5217. // Modify: Modifies the labels applied to the thread. This applies to
  5218. // all messages in the thread.
  5219. func (r *UsersThreadsService) Modify(userId string, id string, modifythreadrequest *ModifyThreadRequest) *UsersThreadsModifyCall {
  5220. c := &UsersThreadsModifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5221. c.userId = userId
  5222. c.id = id
  5223. c.modifythreadrequest = modifythreadrequest
  5224. return c
  5225. }
  5226. // Fields allows partial responses to be retrieved. See
  5227. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5228. // for more information.
  5229. func (c *UsersThreadsModifyCall) Fields(s ...googleapi.Field) *UsersThreadsModifyCall {
  5230. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5231. return c
  5232. }
  5233. // Context sets the context to be used in this call's Do method. Any
  5234. // pending HTTP request will be aborted if the provided context is
  5235. // canceled.
  5236. func (c *UsersThreadsModifyCall) Context(ctx context.Context) *UsersThreadsModifyCall {
  5237. c.ctx_ = ctx
  5238. return c
  5239. }
  5240. func (c *UsersThreadsModifyCall) doRequest(alt string) (*http.Response, error) {
  5241. var body io.Reader = nil
  5242. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifythreadrequest)
  5243. if err != nil {
  5244. return nil, err
  5245. }
  5246. ctype := "application/json"
  5247. c.urlParams_.Set("alt", alt)
  5248. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/modify")
  5249. urls += "?" + c.urlParams_.Encode()
  5250. req, _ := http.NewRequest("POST", urls, body)
  5251. googleapi.Expand(req.URL, map[string]string{
  5252. "userId": c.userId,
  5253. "id": c.id,
  5254. })
  5255. req.Header.Set("Content-Type", ctype)
  5256. req.Header.Set("User-Agent", c.s.userAgent())
  5257. if c.ctx_ != nil {
  5258. return ctxhttp.Do(c.ctx_, c.s.client, req)
  5259. }
  5260. return c.s.client.Do(req)
  5261. }
  5262. // Do executes the "gmail.users.threads.modify" call.
  5263. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  5264. // code is an error. Response headers are in either
  5265. // *Thread.ServerResponse.Header or (if a response was returned at all)
  5266. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5267. // check whether the returned error was because http.StatusNotModified
  5268. // was returned.
  5269. func (c *UsersThreadsModifyCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  5270. gensupport.SetOptions(c.urlParams_, opts...)
  5271. res, err := c.doRequest("json")
  5272. if res != nil && res.StatusCode == http.StatusNotModified {
  5273. if res.Body != nil {
  5274. res.Body.Close()
  5275. }
  5276. return nil, &googleapi.Error{
  5277. Code: res.StatusCode,
  5278. Header: res.Header,
  5279. }
  5280. }
  5281. if err != nil {
  5282. return nil, err
  5283. }
  5284. defer googleapi.CloseBody(res)
  5285. if err := googleapi.CheckResponse(res); err != nil {
  5286. return nil, err
  5287. }
  5288. ret := &Thread{
  5289. ServerResponse: googleapi.ServerResponse{
  5290. Header: res.Header,
  5291. HTTPStatusCode: res.StatusCode,
  5292. },
  5293. }
  5294. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  5295. return nil, err
  5296. }
  5297. return ret, nil
  5298. // {
  5299. // "description": "Modifies the labels applied to the thread. This applies to all messages in the thread.",
  5300. // "httpMethod": "POST",
  5301. // "id": "gmail.users.threads.modify",
  5302. // "parameterOrder": [
  5303. // "userId",
  5304. // "id"
  5305. // ],
  5306. // "parameters": {
  5307. // "id": {
  5308. // "description": "The ID of the thread to modify.",
  5309. // "location": "path",
  5310. // "required": true,
  5311. // "type": "string"
  5312. // },
  5313. // "userId": {
  5314. // "default": "me",
  5315. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5316. // "location": "path",
  5317. // "required": true,
  5318. // "type": "string"
  5319. // }
  5320. // },
  5321. // "path": "{userId}/threads/{id}/modify",
  5322. // "request": {
  5323. // "$ref": "ModifyThreadRequest"
  5324. // },
  5325. // "response": {
  5326. // "$ref": "Thread"
  5327. // },
  5328. // "scopes": [
  5329. // "https://mail.google.com/",
  5330. // "https://www.googleapis.com/auth/gmail.modify"
  5331. // ]
  5332. // }
  5333. }
  5334. // method id "gmail.users.threads.trash":
  5335. type UsersThreadsTrashCall struct {
  5336. s *Service
  5337. userId string
  5338. id string
  5339. urlParams_ gensupport.URLParams
  5340. ctx_ context.Context
  5341. }
  5342. // Trash: Moves the specified thread to the trash.
  5343. func (r *UsersThreadsService) Trash(userId string, id string) *UsersThreadsTrashCall {
  5344. c := &UsersThreadsTrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5345. c.userId = userId
  5346. c.id = id
  5347. return c
  5348. }
  5349. // Fields allows partial responses to be retrieved. See
  5350. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5351. // for more information.
  5352. func (c *UsersThreadsTrashCall) Fields(s ...googleapi.Field) *UsersThreadsTrashCall {
  5353. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5354. return c
  5355. }
  5356. // Context sets the context to be used in this call's Do method. Any
  5357. // pending HTTP request will be aborted if the provided context is
  5358. // canceled.
  5359. func (c *UsersThreadsTrashCall) Context(ctx context.Context) *UsersThreadsTrashCall {
  5360. c.ctx_ = ctx
  5361. return c
  5362. }
  5363. func (c *UsersThreadsTrashCall) doRequest(alt string) (*http.Response, error) {
  5364. var body io.Reader = nil
  5365. c.urlParams_.Set("alt", alt)
  5366. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/trash")
  5367. urls += "?" + c.urlParams_.Encode()
  5368. req, _ := http.NewRequest("POST", urls, body)
  5369. googleapi.Expand(req.URL, map[string]string{
  5370. "userId": c.userId,
  5371. "id": c.id,
  5372. })
  5373. req.Header.Set("User-Agent", c.s.userAgent())
  5374. if c.ctx_ != nil {
  5375. return ctxhttp.Do(c.ctx_, c.s.client, req)
  5376. }
  5377. return c.s.client.Do(req)
  5378. }
  5379. // Do executes the "gmail.users.threads.trash" call.
  5380. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  5381. // code is an error. Response headers are in either
  5382. // *Thread.ServerResponse.Header or (if a response was returned at all)
  5383. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5384. // check whether the returned error was because http.StatusNotModified
  5385. // was returned.
  5386. func (c *UsersThreadsTrashCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  5387. gensupport.SetOptions(c.urlParams_, opts...)
  5388. res, err := c.doRequest("json")
  5389. if res != nil && res.StatusCode == http.StatusNotModified {
  5390. if res.Body != nil {
  5391. res.Body.Close()
  5392. }
  5393. return nil, &googleapi.Error{
  5394. Code: res.StatusCode,
  5395. Header: res.Header,
  5396. }
  5397. }
  5398. if err != nil {
  5399. return nil, err
  5400. }
  5401. defer googleapi.CloseBody(res)
  5402. if err := googleapi.CheckResponse(res); err != nil {
  5403. return nil, err
  5404. }
  5405. ret := &Thread{
  5406. ServerResponse: googleapi.ServerResponse{
  5407. Header: res.Header,
  5408. HTTPStatusCode: res.StatusCode,
  5409. },
  5410. }
  5411. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  5412. return nil, err
  5413. }
  5414. return ret, nil
  5415. // {
  5416. // "description": "Moves the specified thread to the trash.",
  5417. // "httpMethod": "POST",
  5418. // "id": "gmail.users.threads.trash",
  5419. // "parameterOrder": [
  5420. // "userId",
  5421. // "id"
  5422. // ],
  5423. // "parameters": {
  5424. // "id": {
  5425. // "description": "The ID of the thread to Trash.",
  5426. // "location": "path",
  5427. // "required": true,
  5428. // "type": "string"
  5429. // },
  5430. // "userId": {
  5431. // "default": "me",
  5432. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5433. // "location": "path",
  5434. // "required": true,
  5435. // "type": "string"
  5436. // }
  5437. // },
  5438. // "path": "{userId}/threads/{id}/trash",
  5439. // "response": {
  5440. // "$ref": "Thread"
  5441. // },
  5442. // "scopes": [
  5443. // "https://mail.google.com/",
  5444. // "https://www.googleapis.com/auth/gmail.modify"
  5445. // ]
  5446. // }
  5447. }
  5448. // method id "gmail.users.threads.untrash":
  5449. type UsersThreadsUntrashCall struct {
  5450. s *Service
  5451. userId string
  5452. id string
  5453. urlParams_ gensupport.URLParams
  5454. ctx_ context.Context
  5455. }
  5456. // Untrash: Removes the specified thread from the trash.
  5457. func (r *UsersThreadsService) Untrash(userId string, id string) *UsersThreadsUntrashCall {
  5458. c := &UsersThreadsUntrashCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5459. c.userId = userId
  5460. c.id = id
  5461. return c
  5462. }
  5463. // Fields allows partial responses to be retrieved. See
  5464. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5465. // for more information.
  5466. func (c *UsersThreadsUntrashCall) Fields(s ...googleapi.Field) *UsersThreadsUntrashCall {
  5467. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5468. return c
  5469. }
  5470. // Context sets the context to be used in this call's Do method. Any
  5471. // pending HTTP request will be aborted if the provided context is
  5472. // canceled.
  5473. func (c *UsersThreadsUntrashCall) Context(ctx context.Context) *UsersThreadsUntrashCall {
  5474. c.ctx_ = ctx
  5475. return c
  5476. }
  5477. func (c *UsersThreadsUntrashCall) doRequest(alt string) (*http.Response, error) {
  5478. var body io.Reader = nil
  5479. c.urlParams_.Set("alt", alt)
  5480. urls := googleapi.ResolveRelative(c.s.BasePath, "{userId}/threads/{id}/untrash")
  5481. urls += "?" + c.urlParams_.Encode()
  5482. req, _ := http.NewRequest("POST", urls, body)
  5483. googleapi.Expand(req.URL, map[string]string{
  5484. "userId": c.userId,
  5485. "id": c.id,
  5486. })
  5487. req.Header.Set("User-Agent", c.s.userAgent())
  5488. if c.ctx_ != nil {
  5489. return ctxhttp.Do(c.ctx_, c.s.client, req)
  5490. }
  5491. return c.s.client.Do(req)
  5492. }
  5493. // Do executes the "gmail.users.threads.untrash" call.
  5494. // Exactly one of *Thread or error will be non-nil. Any non-2xx status
  5495. // code is an error. Response headers are in either
  5496. // *Thread.ServerResponse.Header or (if a response was returned at all)
  5497. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5498. // check whether the returned error was because http.StatusNotModified
  5499. // was returned.
  5500. func (c *UsersThreadsUntrashCall) Do(opts ...googleapi.CallOption) (*Thread, error) {
  5501. gensupport.SetOptions(c.urlParams_, opts...)
  5502. res, err := c.doRequest("json")
  5503. if res != nil && res.StatusCode == http.StatusNotModified {
  5504. if res.Body != nil {
  5505. res.Body.Close()
  5506. }
  5507. return nil, &googleapi.Error{
  5508. Code: res.StatusCode,
  5509. Header: res.Header,
  5510. }
  5511. }
  5512. if err != nil {
  5513. return nil, err
  5514. }
  5515. defer googleapi.CloseBody(res)
  5516. if err := googleapi.CheckResponse(res); err != nil {
  5517. return nil, err
  5518. }
  5519. ret := &Thread{
  5520. ServerResponse: googleapi.ServerResponse{
  5521. Header: res.Header,
  5522. HTTPStatusCode: res.StatusCode,
  5523. },
  5524. }
  5525. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  5526. return nil, err
  5527. }
  5528. return ret, nil
  5529. // {
  5530. // "description": "Removes the specified thread from the trash.",
  5531. // "httpMethod": "POST",
  5532. // "id": "gmail.users.threads.untrash",
  5533. // "parameterOrder": [
  5534. // "userId",
  5535. // "id"
  5536. // ],
  5537. // "parameters": {
  5538. // "id": {
  5539. // "description": "The ID of the thread to remove from Trash.",
  5540. // "location": "path",
  5541. // "required": true,
  5542. // "type": "string"
  5543. // },
  5544. // "userId": {
  5545. // "default": "me",
  5546. // "description": "The user's email address. The special value me can be used to indicate the authenticated user.",
  5547. // "location": "path",
  5548. // "required": true,
  5549. // "type": "string"
  5550. // }
  5551. // },
  5552. // "path": "{userId}/threads/{id}/untrash",
  5553. // "response": {
  5554. // "$ref": "Thread"
  5555. // },
  5556. // "scopes": [
  5557. // "https://mail.google.com/",
  5558. // "https://www.googleapis.com/auth/gmail.modify"
  5559. // ]
  5560. // }
  5561. }