func (c *SpaceCodebasesController) Create(ctx *app.CreateSpaceCodebasesContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	spaceID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
	}

	// Validate Request
	if ctx.Payload.Data == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data", nil).Expected("not nil"))
	}
	reqIter := ctx.Payload.Data
	if reqIter.Attributes.Type == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data.attributes.type", nil).Expected("not nil"))
	}
	if reqIter.Attributes.URL == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data.attributes.url", nil).Expected("not nil"))
	}

	return application.Transactional(c.db, func(appl application.Application) error {
		_, err = appl.Spaces().Load(ctx, spaceID)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
		}

		newCodeBase := codebase.Codebase{
			SpaceID: spaceID,
			Type:    *reqIter.Attributes.Type,
			URL:     *reqIter.Attributes.URL,
		}
		err = appl.Codebases().Create(ctx, &newCodeBase)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}

		res := &app.CodebaseSingle{
			Data: ConvertCodebase(ctx.RequestData, &newCodeBase),
		}
		ctx.ResponseData.Header().Set("Location", rest.AbsoluteURL(ctx.RequestData, app.CodebaseHref(res.Data.ID)))
		return ctx.Created(res)
	})
}
// Create runs the create action.
Create runs the create action.
// Create runs the create action .
func (c *SpaceCodebasesController) Create(ctx *app.CreateSpaceCodebasesContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	spaceID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
	}
	if ctx.Payload.Data == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data", nil).Expected("not nil"))
	}
	reqIter := ctx.Payload.Data
	if reqIter.Attributes.Type == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data.attributes.type", nil).Expected("not nil"))
	}
	if reqIter.Attributes.URL == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data.attributes.url", nil).Expected("not nil"))
	}
	return application.Transactional(c.db, func(appl application.Application) error {
		_, err = appl.Spaces().Load(ctx, spaceID)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
		}
		newCodeBase := codebase.Codebase{
			SpaceID: spaceID,
			Type:    *reqIter.Attributes.Type,
			URL:     *reqIter.Attributes.URL,
		}
		err = appl.Codebases().Create(ctx, &newCodeBase)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, err)
		}
		res := &app.CodebaseSingle{
			Data: ConvertCodebase(ctx.RequestData, &newCodeBase),
		}
		ctx.ResponseData.Header().Set("Location", rest.AbsoluteURL(ctx.RequestData, app.CodebaseHref(res.Data.ID)))
		return ctx.Created(res)
	})
}
func ( c * SpaceCodebasesController ) Create ( ctx * app . CreateSpaceCodebasesContext ) error { _ , err := login . ContextIdentity ( ctx ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrUnauthorized ( err . Error ( ) ) ) } spaceID , err := uuid . FromString ( ctx . ID ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrNotFound ( err . Error ( ) ) ) } if ctx . Payload . Data == nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewBadParameterError ( " " , nil ) . Expected ( " " ) ) } reqIter := ctx . Payload . Data if reqIter . Attributes . Type == nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewBadParameterError ( " " , nil ) . Expected ( " " ) ) } if reqIter . Attributes . URL == nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewBadParameterError ( " " , nil ) . Expected ( " " ) ) } return application . Transactional ( c . db , func ( appl application . Application ) error { _ , err = appl . Spaces ( ) . Load ( ctx , spaceID ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrNotFound ( err . Error ( ) ) ) } newCodeBase := codebase . Codebase { SpaceID : spaceID , Type : * reqIter . Attributes . Type , URL : * reqIter . Attributes . URL , } err = appl . Codebases ( ) . Create ( ctx , & newCodeBase ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } res := & app . CodebaseSingle { Data : ConvertCodebase ( ctx . RequestData , & newCodeBase ) , } ctx . ResponseData . Header ( ) . Set ( " " , rest . AbsoluteURL ( ctx . RequestData , app . CodebaseHref ( res . Data . ID ) ) ) return ctx . Created ( res ) } ) }
Create runs the create action.
Create runs the create action .
// Validate Request