Skip to content

Commit

Permalink
Fix move files API
Browse files Browse the repository at this point in the history
Describe the body request payload with MoveRequest model.
  • Loading branch information
sevein committed May 13, 2024
1 parent c36ff96 commit 19eeef5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 114 deletions.
27 changes: 0 additions & 27 deletions kiota/api/v2_location_item_with_uu_response.go

This file was deleted.

37 changes: 10 additions & 27 deletions kiota/api/v2_location_with_uu_item_request_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,45 +57,24 @@ func (m *V2LocationWithUuItemRequestBuilder) Get(ctx context.Context, requestCon
return res.(i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.Locationable), nil
}
// Post move files to the specified location.
// Deprecated: This method is obsolete. Use PostAsWithUuPostResponse instead.
// returns a V2LocationItemWithUuResponseable when successful
// returns a []byte when successful
// returns a Error error when the service returns a 400 status code
func (m *V2LocationWithUuItemRequestBuilder) Post(ctx context.Context, requestConfiguration *V2LocationWithUuItemRequestBuilderPostRequestConfiguration)(V2LocationItemWithUuResponseable, error) {
requestInfo, err := m.ToPostRequestInformation(ctx, requestConfiguration);
func (m *V2LocationWithUuItemRequestBuilder) Post(ctx context.Context, body i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveRequestable, requestConfiguration *V2LocationWithUuItemRequestBuilderPostRequestConfiguration)([]byte, error) {
requestInfo, err := m.ToPostRequestInformation(ctx, body, requestConfiguration);
if err != nil {
return nil, err
}
errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings {
"400": i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.CreateErrorFromDiscriminatorValue,
}
res, err := m.BaseRequestBuilder.RequestAdapter.Send(ctx, requestInfo, CreateV2LocationItemWithUuResponseFromDiscriminatorValue, errorMapping)
res, err := m.BaseRequestBuilder.RequestAdapter.SendPrimitive(ctx, requestInfo, "[]byte", errorMapping)
if err != nil {
return nil, err
}
if res == nil {
return nil, nil
}
return res.(V2LocationItemWithUuResponseable), nil
}
// PostAsWithUuPostResponse move files to the specified location.
// returns a V2LocationItemWithUuPostResponseable when successful
// returns a Error error when the service returns a 400 status code
func (m *V2LocationWithUuItemRequestBuilder) PostAsWithUuPostResponse(ctx context.Context, requestConfiguration *V2LocationWithUuItemRequestBuilderPostRequestConfiguration)(V2LocationItemWithUuPostResponseable, error) {
requestInfo, err := m.ToPostRequestInformation(ctx, requestConfiguration);
if err != nil {
return nil, err
}
errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings {
"400": i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.CreateErrorFromDiscriminatorValue,
}
res, err := m.BaseRequestBuilder.RequestAdapter.Send(ctx, requestInfo, CreateV2LocationItemWithUuPostResponseFromDiscriminatorValue, errorMapping)
if err != nil {
return nil, err
}
if res == nil {
return nil, nil
}
return res.(V2LocationItemWithUuPostResponseable), nil
return res.([]byte), nil
}
// returns a *RequestInformation when successful
func (m *V2LocationWithUuItemRequestBuilder) ToGetRequestInformation(ctx context.Context, requestConfiguration *V2LocationWithUuItemRequestBuilderGetRequestConfiguration)(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
Expand All @@ -109,13 +88,17 @@ func (m *V2LocationWithUuItemRequestBuilder) ToGetRequestInformation(ctx context
}
// ToPostRequestInformation move files to the specified location.
// returns a *RequestInformation when successful
func (m *V2LocationWithUuItemRequestBuilder) ToPostRequestInformation(ctx context.Context, requestConfiguration *V2LocationWithUuItemRequestBuilderPostRequestConfiguration)(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
func (m *V2LocationWithUuItemRequestBuilder) ToPostRequestInformation(ctx context.Context, body i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveRequestable, requestConfiguration *V2LocationWithUuItemRequestBuilderPostRequestConfiguration)(*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) {
requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.POST, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters)
if requestConfiguration != nil {
requestInfo.Headers.AddAll(requestConfiguration.Headers)
requestInfo.AddRequestOptions(requestConfiguration.Options)
}
requestInfo.Headers.TryAdd("Accept", "application/json")
err := requestInfo.SetContentFromParsable(ctx, m.BaseRequestBuilder.RequestAdapter, "application/json", body)
if err != nil {
return nil, err
}
return requestInfo, nil
}
// WithUrl returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
Expand Down
2 changes: 1 addition & 1 deletion kiota/kiota-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"descriptionHash": "73D9EF85326177B6AFA48D99BD56278904CD8578BB3F34FF75A63432A62CBE8EBB14F26DED2595501AD7E8776C5BC006558B517F8FCCA67D3F01F431D781E588",
"descriptionHash": "6A474F3CC2C958FBD9951A800B9346F6CBB00A0DAD139711537FDBD49A071E8ACE73DC0ED12BAA735DE36FD1AF10D7AAFF8C21C67B86FD27645D12DC4DF93117",
"descriptionLocation": "../typespec/tsp-output/@typespec/openapi3/openapi.v1.yaml",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.14.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
package api
package models

import (
i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a "go.artefactual.dev/ssclient/kiota/models"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)

type V2LocationItemWithUuPostResponse struct {
type MoveRequest struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additionalData map[string]any
// List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.
files []i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable
files []MoveFileable
// URI of the Location the files should be moved from.
origin_location *string
// URI of the
// URI of the pipeline.
pipeline *string
}
// NewV2LocationItemWithUuPostResponse instantiates a new V2LocationItemWithUuPostResponse and sets the default values.
func NewV2LocationItemWithUuPostResponse()(*V2LocationItemWithUuPostResponse) {
m := &V2LocationItemWithUuPostResponse{
// NewMoveRequest instantiates a new MoveRequest and sets the default values.
func NewMoveRequest()(*MoveRequest) {
m := &MoveRequest{
}
m.SetAdditionalData(make(map[string]any))
return m
}
// CreateV2LocationItemWithUuPostResponseFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value
// CreateMoveRequestFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value
// returns a Parsable when successful
func CreateV2LocationItemWithUuPostResponseFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) {
return NewV2LocationItemWithUuPostResponse(), nil
func CreateMoveRequestFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) {
return NewMoveRequest(), nil
}
// GetAdditionalData gets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
// returns a map[string]any when successful
func (m *V2LocationItemWithUuPostResponse) GetAdditionalData()(map[string]any) {
func (m *MoveRequest) GetAdditionalData()(map[string]any) {
return m.additionalData
}
// GetFieldDeserializers the deserialization information for the current model
// returns a map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error) when successful
func (m *V2LocationItemWithUuPostResponse) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) {
func (m *MoveRequest) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) {
res := make(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error))
res["files"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetCollectionOfObjectValues(i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.CreateMoveFileFromDiscriminatorValue)
val, err := n.GetCollectionOfObjectValues(CreateMoveFileFromDiscriminatorValue)
if err != nil {
return err
}
if val != nil {
res := make([]i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable, len(val))
res := make([]MoveFileable, len(val))
for i, v := range val {
if v != nil {
res[i] = v.(i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable)
res[i] = v.(MoveFileable)
}
}
m.SetFiles(res)
Expand Down Expand Up @@ -76,21 +75,21 @@ func (m *V2LocationItemWithUuPostResponse) GetFieldDeserializers()(map[string]fu
}
// GetFiles gets the files property value. List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.
// returns a []MoveFileable when successful
func (m *V2LocationItemWithUuPostResponse) GetFiles()([]i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable) {
func (m *MoveRequest) GetFiles()([]MoveFileable) {
return m.files
}
// GetOriginLocation gets the origin_location property value. URI of the Location the files should be moved from.
// returns a *string when successful
func (m *V2LocationItemWithUuPostResponse) GetOriginLocation()(*string) {
func (m *MoveRequest) GetOriginLocation()(*string) {
return m.origin_location
}
// GetPipeline gets the pipeline property value. URI of the
// GetPipeline gets the pipeline property value. URI of the pipeline.
// returns a *string when successful
func (m *V2LocationItemWithUuPostResponse) GetPipeline()(*string) {
func (m *MoveRequest) GetPipeline()(*string) {
return m.pipeline
}
// Serialize serializes information the current object
func (m *V2LocationItemWithUuPostResponse) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {
func (m *MoveRequest) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {
if m.GetFiles() != nil {
cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetFiles()))
for i, v := range m.GetFiles() {
Expand Down Expand Up @@ -124,28 +123,28 @@ func (m *V2LocationItemWithUuPostResponse) Serialize(writer i878a80d2330e89d2689
return nil
}
// SetAdditionalData sets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
func (m *V2LocationItemWithUuPostResponse) SetAdditionalData(value map[string]any)() {
func (m *MoveRequest) SetAdditionalData(value map[string]any)() {
m.additionalData = value
}
// SetFiles sets the files property value. List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.
func (m *V2LocationItemWithUuPostResponse) SetFiles(value []i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable)() {
func (m *MoveRequest) SetFiles(value []MoveFileable)() {
m.files = value
}
// SetOriginLocation sets the origin_location property value. URI of the Location the files should be moved from.
func (m *V2LocationItemWithUuPostResponse) SetOriginLocation(value *string)() {
func (m *MoveRequest) SetOriginLocation(value *string)() {
m.origin_location = value
}
// SetPipeline sets the pipeline property value. URI of the
func (m *V2LocationItemWithUuPostResponse) SetPipeline(value *string)() {
// SetPipeline sets the pipeline property value. URI of the pipeline.
func (m *MoveRequest) SetPipeline(value *string)() {
m.pipeline = value
}
type V2LocationItemWithUuPostResponseable interface {
type MoveRequestable interface {
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.AdditionalDataHolder
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable
GetFiles()([]i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable)
GetFiles()([]MoveFileable)
GetOriginLocation()(*string)
GetPipeline()(*string)
SetFiles(value []i2b7a3625368152c59661ed1a63c26960f7e9cda05d0fbc8e5d79ac57ca250e0a.MoveFileable)()
SetFiles(value []MoveFileable)()
SetOriginLocation(value *string)()
SetPipeline(value *string)()
}
26 changes: 18 additions & 8 deletions typespec/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ namespace Service {

@doc("Move files to the specified location.")
@post
op move(@path uuid: uuid): {
@doc("URI of the Location the files should be moved from.")
origin_location: uri;
op move(
@path
uuid: uuid,

@doc("URI of the")
pipeline: uri;

@doc("List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.")
files: moveFilesList;
@body
body: MoveRequest,
): {
@statusCode statusCode: 200;
} | {
@statusCode statusCode: 400;
@body error: Error;
Expand Down Expand Up @@ -187,6 +186,17 @@ model LocationList {
...ListResponse<Location>;
}

model MoveRequest {
@doc("URI of the Location the files should be moved from.")
origin_location: uri;

@doc("URI of the pipeline.")
pipeline: uri;

@doc("List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.")
files: moveFilesList;
}

alias moveFilesList = moveFile[];

model moveFile {
Expand Down
48 changes: 26 additions & 22 deletions typespec/tsp-output/@typespec/openapi3/openapi.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,6 @@ paths:
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
type: object
properties:
origin_location:
allOf:
- $ref: '#/components/schemas/uri'
description: URI of the Location the files should be moved from.
pipeline:
allOf:
- $ref: '#/components/schemas/uri'
description: URI of the
files:
type: array
items:
$ref: '#/components/schemas/moveFile'
description: List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.
required:
- origin_location
- pipeline
- files
'400':
description: The server could not understand the request due to invalid syntax.
content:
Expand All @@ -144,6 +122,12 @@ paths:
$ref: '#/components/schemas/Error'
'404':
description: The server cannot find the requested resource.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MoveRequest'
/api/v2/pipeline:
get:
operationId: Pipelines_list
Expand Down Expand Up @@ -304,6 +288,26 @@ components:
- BL
- TS
- RP
MoveRequest:
type: object
required:
- origin_location
- pipeline
- files
properties:
origin_location:
allOf:
- $ref: '#/components/schemas/uri'
description: URI of the Location the files should be moved from.
pipeline:
allOf:
- $ref: '#/components/schemas/uri'
description: URI of the pipeline.
files:
type: array
items:
$ref: '#/components/schemas/moveFile'
description: List of objects containing `source` and `destination`. The source and destination are paths relative to their Location of the files to be moved.
Pipeline:
type: object
required:
Expand Down

0 comments on commit 19eeef5

Please sign in to comment.