@@ -345,6 +345,119 @@ export class SchemaApi {
345345 ) ;
346346 } ) ;
347347 }
348+ /**
349+ * Deleting a schema field removes it from all records within the collection, however, references to the schema field in pipelines are not removed. > Note: This operation cannot be reversed.
350+ * @summary Delete schema field
351+ * @param collectionId The collection the schema field belongs to, e.g. `my-collection`.
352+ * @param schemaFieldName The name of the schema field to delete.
353+ */
354+ public async deleteSchemaField (
355+ collectionId : string ,
356+ schemaFieldName : string ,
357+ options : { headers : { [ name : string ] : string } } = { headers : { } }
358+ ) : Promise < { response : http . IncomingMessage ; body : any } > {
359+ const localVarPath =
360+ this . basePath +
361+ "/v4/collections/{collection_id}/schemaFields/{schema_field_name}"
362+ . replace (
363+ "{" + "collection_id" + "}" ,
364+ encodeURIComponent ( String ( collectionId ) )
365+ )
366+ . replace (
367+ "{" + "schema_field_name" + "}" ,
368+ encodeURIComponent ( String ( schemaFieldName ) )
369+ ) ;
370+ let localVarQueryParameters : any = { } ;
371+ let localVarHeaderParams : any = ( < any > Object ) . assign (
372+ { } ,
373+ this . _defaultHeaders
374+ ) ;
375+ const produces = [ "application/json" ] ;
376+ // give precedence to 'application/json'
377+ if ( produces . indexOf ( "application/json" ) >= 0 ) {
378+ localVarHeaderParams . Accept = "application/json" ;
379+ } else {
380+ localVarHeaderParams . Accept = produces . join ( "," ) ;
381+ }
382+ let localVarFormParams : any = { } ;
383+
384+ // verify required parameter 'collectionId' is not null or undefined
385+ if ( collectionId === null || collectionId === undefined ) {
386+ throw new Error (
387+ "Required parameter collectionId was null or undefined when calling deleteSchemaField."
388+ ) ;
389+ }
390+
391+ // verify required parameter 'schemaFieldName' is not null or undefined
392+ if ( schemaFieldName === null || schemaFieldName === undefined ) {
393+ throw new Error (
394+ "Required parameter schemaFieldName was null or undefined when calling deleteSchemaField."
395+ ) ;
396+ }
397+
398+ ( < any > Object ) . assign ( localVarHeaderParams , options . headers ) ;
399+
400+ let localVarUseFormData = false ;
401+
402+ let localVarRequestOptions : localVarRequest . Options = {
403+ method : "DELETE" ,
404+ qs : localVarQueryParameters ,
405+ headers : localVarHeaderParams ,
406+ uri : localVarPath ,
407+ useQuerystring : this . _useQuerystring ,
408+ json : true ,
409+ } ;
410+
411+ let authenticationPromise = Promise . resolve ( ) ;
412+ if (
413+ this . authentications . BasicAuth . username &&
414+ this . authentications . BasicAuth . password
415+ ) {
416+ authenticationPromise = authenticationPromise . then ( ( ) =>
417+ this . authentications . BasicAuth . applyToRequest ( localVarRequestOptions )
418+ ) ;
419+ }
420+ authenticationPromise = authenticationPromise . then ( ( ) =>
421+ this . authentications . default . applyToRequest ( localVarRequestOptions )
422+ ) ;
423+
424+ let interceptorPromise = authenticationPromise ;
425+ for ( const interceptor of this . interceptors ) {
426+ interceptorPromise = interceptorPromise . then ( ( ) =>
427+ interceptor ( localVarRequestOptions )
428+ ) ;
429+ }
430+
431+ return interceptorPromise . then ( ( ) => {
432+ if ( Object . keys ( localVarFormParams ) . length ) {
433+ if ( localVarUseFormData ) {
434+ ( < any > localVarRequestOptions ) . formData = localVarFormParams ;
435+ } else {
436+ localVarRequestOptions . form = localVarFormParams ;
437+ }
438+ }
439+ return new Promise < { response : http . IncomingMessage ; body : any } > (
440+ ( resolve , reject ) => {
441+ localVarRequest ( localVarRequestOptions , ( error , response , body ) => {
442+ if ( error ) {
443+ reject ( error ) ;
444+ } else {
445+ if (
446+ response . statusCode &&
447+ response . statusCode >= 200 &&
448+ response . statusCode <= 299
449+ ) {
450+ body = ObjectSerializer . deserialize ( body , "any" ) ;
451+ resolve ( { response : response , body : body } ) ;
452+ } else {
453+ reject ( new HttpError ( response , body , response . statusCode ) ) ;
454+ }
455+ }
456+ } ) ;
457+ }
458+ ) ;
459+ } ) ;
460+ }
348461 /**
349462 * Retrieve a list of schema fields in a collection.
350463 * @summary List schema fields
@@ -469,4 +582,136 @@ export class SchemaApi {
469582 } ) ;
470583 } ) ;
471584 }
585+ /**
586+ * Update the details of a schema field. Only `name` and `description` can be updated.
587+ * @summary Update schema field
588+ * @param collectionId The collection the schema field belongs to, e.g. `my-collection`.
589+ * @param schemaFieldName The name of the schema field to update.
590+ * @param schemaField The schema field details to update.
591+ * @param updateMask The list of fields to update, separated by a comma, e.g. `name,description`. Each field should be in snake case. For each field that you want to update, provide a corresponding value in the schema field object containing the new value.
592+ */
593+ public async updateSchemaField (
594+ collectionId : string ,
595+ schemaFieldName : string ,
596+ schemaField : SchemaField ,
597+ updateMask ?: string ,
598+ options : { headers : { [ name : string ] : string } } = { headers : { } }
599+ ) : Promise < { response : http . IncomingMessage ; body : SchemaField } > {
600+ const localVarPath =
601+ this . basePath +
602+ "/v4/collections/{collection_id}/schemaFields/{schema_field_name}"
603+ . replace (
604+ "{" + "collection_id" + "}" ,
605+ encodeURIComponent ( String ( collectionId ) )
606+ )
607+ . replace (
608+ "{" + "schema_field_name" + "}" ,
609+ encodeURIComponent ( String ( schemaFieldName ) )
610+ ) ;
611+ let localVarQueryParameters : any = { } ;
612+ let localVarHeaderParams : any = ( < any > Object ) . assign (
613+ { } ,
614+ this . _defaultHeaders
615+ ) ;
616+ const produces = [ "application/json" ] ;
617+ // give precedence to 'application/json'
618+ if ( produces . indexOf ( "application/json" ) >= 0 ) {
619+ localVarHeaderParams . Accept = "application/json" ;
620+ } else {
621+ localVarHeaderParams . Accept = produces . join ( "," ) ;
622+ }
623+ let localVarFormParams : any = { } ;
624+
625+ // verify required parameter 'collectionId' is not null or undefined
626+ if ( collectionId === null || collectionId === undefined ) {
627+ throw new Error (
628+ "Required parameter collectionId was null or undefined when calling updateSchemaField."
629+ ) ;
630+ }
631+
632+ // verify required parameter 'schemaFieldName' is not null or undefined
633+ if ( schemaFieldName === null || schemaFieldName === undefined ) {
634+ throw new Error (
635+ "Required parameter schemaFieldName was null or undefined when calling updateSchemaField."
636+ ) ;
637+ }
638+
639+ // verify required parameter 'schemaField' is not null or undefined
640+ if ( schemaField === null || schemaField === undefined ) {
641+ throw new Error (
642+ "Required parameter schemaField was null or undefined when calling updateSchemaField."
643+ ) ;
644+ }
645+
646+ if ( updateMask !== undefined ) {
647+ localVarQueryParameters [ "update_mask" ] = ObjectSerializer . serialize (
648+ updateMask ,
649+ "string"
650+ ) ;
651+ }
652+
653+ ( < any > Object ) . assign ( localVarHeaderParams , options . headers ) ;
654+
655+ let localVarUseFormData = false ;
656+
657+ let localVarRequestOptions : localVarRequest . Options = {
658+ method : "PATCH" ,
659+ qs : localVarQueryParameters ,
660+ headers : localVarHeaderParams ,
661+ uri : localVarPath ,
662+ useQuerystring : this . _useQuerystring ,
663+ json : true ,
664+ body : ObjectSerializer . serialize ( schemaField , "SchemaField" ) ,
665+ } ;
666+
667+ let authenticationPromise = Promise . resolve ( ) ;
668+ if (
669+ this . authentications . BasicAuth . username &&
670+ this . authentications . BasicAuth . password
671+ ) {
672+ authenticationPromise = authenticationPromise . then ( ( ) =>
673+ this . authentications . BasicAuth . applyToRequest ( localVarRequestOptions )
674+ ) ;
675+ }
676+ authenticationPromise = authenticationPromise . then ( ( ) =>
677+ this . authentications . default . applyToRequest ( localVarRequestOptions )
678+ ) ;
679+
680+ let interceptorPromise = authenticationPromise ;
681+ for ( const interceptor of this . interceptors ) {
682+ interceptorPromise = interceptorPromise . then ( ( ) =>
683+ interceptor ( localVarRequestOptions )
684+ ) ;
685+ }
686+
687+ return interceptorPromise . then ( ( ) => {
688+ if ( Object . keys ( localVarFormParams ) . length ) {
689+ if ( localVarUseFormData ) {
690+ ( < any > localVarRequestOptions ) . formData = localVarFormParams ;
691+ } else {
692+ localVarRequestOptions . form = localVarFormParams ;
693+ }
694+ }
695+ return new Promise < { response : http . IncomingMessage ; body : SchemaField } > (
696+ ( resolve , reject ) => {
697+ localVarRequest ( localVarRequestOptions , ( error , response , body ) => {
698+ if ( error ) {
699+ reject ( error ) ;
700+ } else {
701+ if (
702+ response . statusCode &&
703+ response . statusCode >= 200 &&
704+ response . statusCode <= 299
705+ ) {
706+ body = ObjectSerializer . deserialize ( body , "SchemaField" ) ;
707+ resolve ( { response : response , body : body } ) ;
708+ } else {
709+ reject ( new HttpError ( response , body , response . statusCode ) ) ;
710+ }
711+ }
712+ } ) ;
713+ }
714+ ) ;
715+ } ) ;
716+ }
472717}
0 commit comments