@@ -1935,6 +1935,208 @@ func (s *Artifacts) Preflight(ctx context.Context, request *shared.PreflightRequ
1935
1935
1936
1936
}
1937
1937
1938
+ // SetArchived - Set whether a namespace is archived
1939
+ func (s * Artifacts ) SetArchived (ctx context.Context , request operations.ArchiveNamespaceRequest , opts ... operations.Option ) (* operations.ArchiveNamespaceResponse , error ) {
1940
+ hookCtx := hooks.HookContext {
1941
+ Context : ctx ,
1942
+ OperationID : "archiveNamespace" ,
1943
+ OAuth2Scopes : []string {},
1944
+ SecuritySource : s .sdkConfiguration .Security ,
1945
+ }
1946
+
1947
+ o := operations.Options {}
1948
+ supportedOptions := []string {
1949
+ operations .SupportedOptionRetries ,
1950
+ operations .SupportedOptionTimeout ,
1951
+ }
1952
+
1953
+ for _ , opt := range opts {
1954
+ if err := opt (& o , supportedOptions ... ); err != nil {
1955
+ return nil , fmt .Errorf ("error applying option: %w" , err )
1956
+ }
1957
+ }
1958
+
1959
+ var baseURL string
1960
+ if o .ServerURL == nil {
1961
+ baseURL = utils .ReplaceParameters (s .sdkConfiguration .GetServerDetails ())
1962
+ } else {
1963
+ baseURL = * o .ServerURL
1964
+ }
1965
+ opURL , err := utils .GenerateURL (ctx , baseURL , "/v1/artifacts/namespaces/{namespace_name}/archive" , request , nil )
1966
+ if err != nil {
1967
+ return nil , fmt .Errorf ("error generating URL: %w" , err )
1968
+ }
1969
+
1970
+ bodyReader , reqContentType , err := utils .SerializeRequestBody (ctx , request , false , true , "RequestBody" , "json" , `request:"mediaType=application/json"` )
1971
+ if err != nil {
1972
+ return nil , err
1973
+ }
1974
+
1975
+ timeout := o .Timeout
1976
+ if timeout == nil {
1977
+ timeout = s .sdkConfiguration .Timeout
1978
+ }
1979
+
1980
+ if timeout != nil {
1981
+ var cancel context.CancelFunc
1982
+ ctx , cancel = context .WithTimeout (ctx , * timeout )
1983
+ defer cancel ()
1984
+ }
1985
+
1986
+ req , err := http .NewRequestWithContext (ctx , "POST" , opURL , bodyReader )
1987
+ if err != nil {
1988
+ return nil , fmt .Errorf ("error creating request: %w" , err )
1989
+ }
1990
+ req .Header .Set ("Accept" , "application/json" )
1991
+ req .Header .Set ("User-Agent" , s .sdkConfiguration .UserAgent )
1992
+ if reqContentType != "" {
1993
+ req .Header .Set ("Content-Type" , reqContentType )
1994
+ }
1995
+
1996
+ if err := utils .PopulateSecurity (ctx , req , s .sdkConfiguration .Security ); err != nil {
1997
+ return nil , err
1998
+ }
1999
+
2000
+ for k , v := range o .SetHeaders {
2001
+ req .Header .Set (k , v )
2002
+ }
2003
+
2004
+ globalRetryConfig := s .sdkConfiguration .RetryConfig
2005
+ retryConfig := o .Retries
2006
+ if retryConfig == nil {
2007
+ if globalRetryConfig != nil {
2008
+ retryConfig = globalRetryConfig
2009
+ }
2010
+ }
2011
+
2012
+ var httpRes * http.Response
2013
+ if retryConfig != nil {
2014
+ httpRes , err = utils .Retry (ctx , utils.Retries {
2015
+ Config : retryConfig ,
2016
+ StatusCodes : []string {
2017
+ "429" ,
2018
+ "500" ,
2019
+ "502" ,
2020
+ "503" ,
2021
+ "504" ,
2022
+ },
2023
+ }, func () (* http.Response , error ) {
2024
+ if req .Body != nil {
2025
+ copyBody , err := req .GetBody ()
2026
+ if err != nil {
2027
+ return nil , err
2028
+ }
2029
+ req .Body = copyBody
2030
+ }
2031
+
2032
+ req , err = s .sdkConfiguration .Hooks .BeforeRequest (hooks.BeforeRequestContext {HookContext : hookCtx }, req )
2033
+ if err != nil {
2034
+ if retry .IsPermanentError (err ) || retry .IsTemporaryError (err ) {
2035
+ return nil , err
2036
+ }
2037
+
2038
+ return nil , retry .Permanent (err )
2039
+ }
2040
+
2041
+ httpRes , err := s .sdkConfiguration .Client .Do (req )
2042
+ if err != nil || httpRes == nil {
2043
+ if err != nil {
2044
+ err = fmt .Errorf ("error sending request: %w" , err )
2045
+ } else {
2046
+ err = fmt .Errorf ("error sending request: no response" )
2047
+ }
2048
+
2049
+ _ , err = s .sdkConfiguration .Hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
2050
+ }
2051
+ return httpRes , err
2052
+ })
2053
+
2054
+ if err != nil {
2055
+ return nil , err
2056
+ } else {
2057
+ httpRes , err = s .sdkConfiguration .Hooks .AfterSuccess (hooks.AfterSuccessContext {HookContext : hookCtx }, httpRes )
2058
+ if err != nil {
2059
+ return nil , err
2060
+ }
2061
+ }
2062
+ } else {
2063
+ req , err = s .sdkConfiguration .Hooks .BeforeRequest (hooks.BeforeRequestContext {HookContext : hookCtx }, req )
2064
+ if err != nil {
2065
+ return nil , err
2066
+ }
2067
+
2068
+ httpRes , err = s .sdkConfiguration .Client .Do (req )
2069
+ if err != nil || httpRes == nil {
2070
+ if err != nil {
2071
+ err = fmt .Errorf ("error sending request: %w" , err )
2072
+ } else {
2073
+ err = fmt .Errorf ("error sending request: no response" )
2074
+ }
2075
+
2076
+ _ , err = s .sdkConfiguration .Hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, nil , err )
2077
+ return nil , err
2078
+ } else if utils .MatchStatusCodes ([]string {"4XX" , "5XX" }, httpRes .StatusCode ) {
2079
+ _httpRes , err := s .sdkConfiguration .Hooks .AfterError (hooks.AfterErrorContext {HookContext : hookCtx }, httpRes , nil )
2080
+ if err != nil {
2081
+ return nil , err
2082
+ } else if _httpRes != nil {
2083
+ httpRes = _httpRes
2084
+ }
2085
+ } else {
2086
+ httpRes , err = s .sdkConfiguration .Hooks .AfterSuccess (hooks.AfterSuccessContext {HookContext : hookCtx }, httpRes )
2087
+ if err != nil {
2088
+ return nil , err
2089
+ }
2090
+ }
2091
+ }
2092
+
2093
+ res := & operations.ArchiveNamespaceResponse {
2094
+ StatusCode : httpRes .StatusCode ,
2095
+ ContentType : httpRes .Header .Get ("Content-Type" ),
2096
+ RawResponse : httpRes ,
2097
+ }
2098
+
2099
+ switch {
2100
+ case httpRes .StatusCode >= 200 && httpRes .StatusCode < 300 :
2101
+ case httpRes .StatusCode >= 400 && httpRes .StatusCode < 500 :
2102
+ switch {
2103
+ case utils .MatchContentType (httpRes .Header .Get ("Content-Type" ), `application/json` ):
2104
+ rawBody , err := utils .ConsumeRawBody (httpRes )
2105
+ if err != nil {
2106
+ return nil , err
2107
+ }
2108
+
2109
+ var out sdkerrors.Error
2110
+ if err := utils .UnmarshalJsonFromResponseBody (bytes .NewBuffer (rawBody ), & out , "" ); err != nil {
2111
+ return nil , err
2112
+ }
2113
+
2114
+ return nil , & out
2115
+ default :
2116
+ rawBody , err := utils .ConsumeRawBody (httpRes )
2117
+ if err != nil {
2118
+ return nil , err
2119
+ }
2120
+ return nil , sdkerrors .NewSDKError (fmt .Sprintf ("unknown content-type received: %s" , httpRes .Header .Get ("Content-Type" )), httpRes .StatusCode , string (rawBody ), httpRes )
2121
+ }
2122
+ case httpRes .StatusCode >= 500 && httpRes .StatusCode < 600 :
2123
+ rawBody , err := utils .ConsumeRawBody (httpRes )
2124
+ if err != nil {
2125
+ return nil , err
2126
+ }
2127
+ return nil , sdkerrors .NewSDKError ("API error occurred" , httpRes .StatusCode , string (rawBody ), httpRes )
2128
+ default :
2129
+ rawBody , err := utils .ConsumeRawBody (httpRes )
2130
+ if err != nil {
2131
+ return nil , err
2132
+ }
2133
+ return nil , sdkerrors .NewSDKError ("unknown status code returned" , httpRes .StatusCode , string (rawBody ), httpRes )
2134
+ }
2135
+
2136
+ return res , nil
2137
+
2138
+ }
2139
+
1938
2140
// SetVisibility - Set visibility of a namespace with an existing metadata entry
1939
2141
func (s * Artifacts ) SetVisibility (ctx context.Context , request operations.SetVisibilityRequest , opts ... operations.Option ) (* operations.SetVisibilityResponse , error ) {
1940
2142
hookCtx := hooks.HookContext {
0 commit comments