Skip to content

Commit 351bace

Browse files
Refactor App Config tsp (Azure#32338)
* add aliases and fix casing * update alias casing * refactor shared code * create alias for shared request params * clean up implementation * merge more request params * format * update alias --------- Co-authored-by: catalinaperalta <caperal@microsoft.com>
1 parent 58ca4b7 commit 351bace

File tree

3 files changed

+303
-661
lines changed

3 files changed

+303
-661
lines changed

specification/appconfiguration/AppConfiguration/models.tsp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,116 @@ model OperationDetails {
328328
""")
329329
error?: Foundations.Error;
330330
}
331+
332+
alias SyncTokenHeader = {
333+
@doc("Used to guarantee real-time consistency between requests.")
334+
@header("Sync-Token")
335+
syncToken?: string;
336+
};
337+
338+
#suppress "@azure-tools/typespec-azure-core/no-closed-literal-union" "Needs fix: https://github.com/microsoft/typespec/issues/2853"
339+
alias ContentTypeHeader<T extends string> = {
340+
@doc("Content-Type header")
341+
@header("Content-Type")
342+
contentType?: T | "application/problem+json";
343+
};
344+
345+
alias AppConfigResponseHeaders = {
346+
...SyncTokenHeader;
347+
348+
@doc("A value representing the current state of the resource.")
349+
@header("ETag")
350+
etagHeader?: string;
351+
};
352+
353+
alias AfterHeader = {
354+
@doc("""
355+
Instructs the server to return elements that appear after the element referred
356+
to by the specified token.
357+
""")
358+
@query("After")
359+
after?: string;
360+
};
361+
362+
alias AcceptDatetimeHeader = {
363+
@doc("""
364+
Requests the server to respond with the state of the resource at the specified
365+
time.
366+
""")
367+
@header("Accept-Datetime")
368+
acceptDatetime?: string;
369+
};
370+
371+
alias SelectQueryParam<Type extends TypeSpec.Reflection.Model | string> = {
372+
@doc("Used to select what fields are present in the returned resource(s).")
373+
@query("$Select")
374+
select?: Type[];
375+
};
376+
377+
alias NameQueryParam<TDoc extends valueof string> = {
378+
@doc(TDoc)
379+
@query("name")
380+
name?: string;
381+
};
382+
383+
alias KeyQueryParam<TDoc extends valueof string> = {
384+
@doc(TDoc)
385+
@query("key")
386+
key?: string;
387+
};
388+
389+
alias IfMatchHeader = {
390+
@doc("""
391+
Used to perform an operation only if the targeted resource's etag matches the
392+
value provided.
393+
""")
394+
@header("If-Match")
395+
ifMatch?: string;
396+
};
397+
398+
alias IfNoneMatchHeader = {
399+
@doc("""
400+
Used to perform an operation only if the targeted resource's etag does not
401+
match the value provided.
402+
""")
403+
@header("If-None-Match")
404+
ifNoneMatch?: string;
405+
};
406+
407+
alias KeyPathParam<TDoc extends valueof string> = {
408+
@doc(TDoc)
409+
@path
410+
key: string;
411+
};
412+
413+
alias LabelQueryParam<TDoc extends valueof string> = {
414+
@doc(TDoc)
415+
@query("label")
416+
label?: string;
417+
};
418+
419+
alias SnapshotOptionalQueryParam<TDoc extends valueof string> = {
420+
@doc(TDoc)
421+
@query("snapshot")
422+
snapshot?: string;
423+
};
424+
425+
alias TagsQueryParam<TDoc extends valueof string> = {
426+
#suppress "@azure-tools/typespec-azure-core/no-query-explode" "Pre-existing API contract."
427+
@doc(TDoc)
428+
@query(#{ name: "tags", explode: true })
429+
tags?: string[];
430+
};
431+
432+
alias LinkHeader = {
433+
@doc("Includes links to related resources.")
434+
@header("Link")
435+
link?: string;
436+
};
437+
438+
alias NamePathParam<TDoc extends valueof string> = {
439+
@doc(TDoc)
440+
@maxLength(256)
441+
@path
442+
name: string;
443+
};

0 commit comments

Comments
 (0)