Skip to content

Commit

Permalink
Merge pull request #254 from tbaert-prest/main
Browse files Browse the repository at this point in the history
Add ObjectTypeAttribute Payload for the creation and the update of the Assets Object Type Attribute
  • Loading branch information
ctreminiom authored Mar 8, 2024
2 parents 1c885a2 + d516aea commit 810da40
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 59 deletions.
8 changes: 4 additions & 4 deletions assets/internal/object_type_attribute_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type ObjectTypeAttributeService struct {
// POST /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}
//
// https://docs.go-atlassian.io/jira-assets/object/type/attribute#create-object-type-attribute
func (o *ObjectTypeAttributeService) Create(ctx context.Context, workspaceID, objectTypeID string, payload *model.ObjectTypeAttributeScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {
func (o *ObjectTypeAttributeService) Create(ctx context.Context, workspaceID, objectTypeID string, payload *model.ObjectTypeAttributePayloadScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {
return o.internalClient.Create(ctx, workspaceID, objectTypeID, payload)
}

Expand All @@ -34,7 +34,7 @@ func (o *ObjectTypeAttributeService) Create(ctx context.Context, workspaceID, ob
// PUT /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}/{id}
//
// https://docs.go-atlassian.io/jira-assets/object/type/attribute#update-object-type-attribute
func (o *ObjectTypeAttributeService) Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *model.ObjectTypeAttributeScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {
func (o *ObjectTypeAttributeService) Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *model.ObjectTypeAttributePayloadScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {
return o.internalClient.Update(ctx, workspaceID, objectTypeID, attributeID, payload)
}

Expand All @@ -51,7 +51,7 @@ type internalObjectTypeAttributeImpl struct {
c service.Connector
}

func (i *internalObjectTypeAttributeImpl) Create(ctx context.Context, workspaceID, objectTypeID string, payload *model.ObjectTypeAttributeScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {
func (i *internalObjectTypeAttributeImpl) Create(ctx context.Context, workspaceID, objectTypeID string, payload *model.ObjectTypeAttributePayloadScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {

if workspaceID == "" {
return nil, nil, model.ErrNoWorkspaceIDError
Expand All @@ -77,7 +77,7 @@ func (i *internalObjectTypeAttributeImpl) Create(ctx context.Context, workspaceI
return attribute, res, nil
}

func (i *internalObjectTypeAttributeImpl) Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *model.ObjectTypeAttributeScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {
func (i *internalObjectTypeAttributeImpl) Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *model.ObjectTypeAttributePayloadScheme) (*model.ObjectTypeAttributeScheme, *model.ResponseScheme, error) {

if workspaceID == "" {
return nil, nil, model.ErrNoWorkspaceIDError
Expand Down
87 changes: 34 additions & 53 deletions assets/internal/object_type_attribute_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,34 @@ import (
)

func Test_internalObjectTypeAttributeImpl_Create(t *testing.T) {

payloadMocked := &model.ObjectTypeAttributeScheme{
WorkspaceId: "g2778e1d-939d-581d-c8e2-9d5g59de456b",
GlobalId: "g2778e1d-939d-581d-c8e2-9d5g59de456b:1330",
ID: "1330",
ObjectType: nil,
Name: "Geolocation",
Label: false,
Type: 0,
Description: "",
DefaultType: &model.ObjectTypeAssetAttributeDefaultTypeScheme{
ID: 0,
Name: "Text",
},
var attributeType int
var defaultTypeID int
var minimumCardinality int
var maximumCardinality int
attributeType = 0
defaultTypeID = 0
minimumCardinality = 0
maximumCardinality = 0
payloadMocked := &model.ObjectTypeAttributePayloadScheme{
Name: "Geolocation",
Label: false,
Type: &attributeType,
Description: "",
DefaultTypeId: &defaultTypeID,
TypeValue: "",
TypeValueMulti: nil,
AdditionalValue: "",
ReferenceType: nil,
ReferenceObjectTypeId: "",
ReferenceObjectType: nil,
Editable: false,
System: false,
Indexed: false,
Sortable: false,
Summable: false,
MinimumCardinality: 0,
MaximumCardinality: 0,
MinimumCardinality: &minimumCardinality,
MaximumCardinality: &maximumCardinality,
Suffix: "",
Removable: false,
ObjectAttributeExists: false,
Hidden: false,
IncludeChildObjectTypes: false,
UniqueAttribute: false,
RegexValidation: "",
Iql: "",
QlQuery: "",
Options: "",
Position: 6,
}

type fields struct {
Expand All @@ -59,7 +49,7 @@ func Test_internalObjectTypeAttributeImpl_Create(t *testing.T) {
type args struct {
ctx context.Context
workspaceID, objectTypeID string
payload *model.ObjectTypeAttributeScheme
payload *model.ObjectTypeAttributePayloadScheme
}

testCases := []struct {
Expand Down Expand Up @@ -182,43 +172,34 @@ func Test_internalObjectTypeAttributeImpl_Create(t *testing.T) {

func Test_internalObjectTypeAttributeImpl_Update(t *testing.T) {

payloadMocked := &model.ObjectTypeAttributeScheme{
WorkspaceId: "g2778e1d-939d-581d-c8e2-9d5g59de456b",
GlobalId: "g2778e1d-939d-581d-c8e2-9d5g59de456b:1330",
ID: "1330",
ObjectType: nil,
Name: "Geolocation",
Label: false,
Type: 0,
Description: "",
DefaultType: &model.ObjectTypeAssetAttributeDefaultTypeScheme{
ID: 0,
Name: "Text",
},
var attributeType int
var defaultTypeID int
var minimumCardinality int
var maximumCardinality int
attributeType = 0
defaultTypeID = 0
minimumCardinality = 0
maximumCardinality = 0
payloadMocked := &model.ObjectTypeAttributePayloadScheme{
Name: "Geolocation",
Label: false,
Type: &attributeType,
Description: "",
DefaultTypeId: &defaultTypeID,
TypeValue: "",
TypeValueMulti: nil,
AdditionalValue: "",
ReferenceType: nil,
ReferenceObjectTypeId: "",
ReferenceObjectType: nil,
Editable: false,
System: false,
Indexed: false,
Sortable: false,
Summable: false,
MinimumCardinality: 0,
MaximumCardinality: 0,
MinimumCardinality: &minimumCardinality,
MaximumCardinality: &maximumCardinality,
Suffix: "",
Removable: false,
ObjectAttributeExists: false,
Hidden: false,
IncludeChildObjectTypes: false,
UniqueAttribute: false,
RegexValidation: "",
Iql: "",
QlQuery: "",
Options: "",
Position: 6,
}

type fields struct {
Expand All @@ -228,7 +209,7 @@ func Test_internalObjectTypeAttributeImpl_Update(t *testing.T) {
type args struct {
ctx context.Context
workspaceID, objectTypeID, attributeID string
payload *model.ObjectTypeAttributeScheme
payload *model.ObjectTypeAttributePayloadScheme
}

testCases := []struct {
Expand Down
22 changes: 22 additions & 0 deletions pkg/infra/models/assets_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ type ObjectAttributeScheme struct {
ObjectAttributeValues []*ObjectTypeAssetAttributeValueScheme `json:"objectAttributeValues,omitempty"`
}

type ObjectTypeAttributePayloadScheme struct {
Name string `json:"name,omitempty"`
Label bool `json:"label,omitempty"`
Description string `json:"description,omitempty"`
Type *int `json:"type,omitempty"`
DefaultTypeId *int `json:"defaultTypeId,omitempty"`
TypeValue string `json:"typeValue,omitempty"`
TypeValueMulti []string `json:"typeValueMulti,omitempty"`
AdditionalValue string `json:"additionalValue,omitempty"`
MinimumCardinality *int `json:"minimumCardinality,omitempty"`
MaximumCardinality *int `json:"maximumCardinality,omitempty"`
Suffix string `json:"suffix,omitempty"`
IncludeChildObjectTypes bool `json:"includeChildObjectTypes,omitempty"`
Hidden bool `json:"hidden,omitempty"`
UniqueAttribute bool `json:"uniqueAttribute,omitempty"`
Summable bool `json:"summable,omitempty"`
RegexValidation string `json:"regexValidation,omitempty"`
QlQuery string `json:"qlQuery,omitempty"`
Iql string `json:"iql,omitempty"`
Options string `json:"options,omitempty"`
}

type ObjectTypeAttributeScheme struct {
WorkspaceId string `json:"workspaceId,omitempty"`
GlobalId string `json:"globalId,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions service/assets/object_type_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ type ObjectTypeAttributeConnector interface {
// POST /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}
//
// https://docs.go-atlassian.io/jira-assets/object/type/attribute#create-object-type-attribute
Create(ctx context.Context, workspaceID, objectTypeID string, payload *models.ObjectTypeAttributeScheme) (
Create(ctx context.Context, workspaceID, objectTypeID string, payload *models.ObjectTypeAttributePayloadScheme) (
*models.ObjectTypeAttributeScheme, *models.ResponseScheme, error)

// Update updates an existing object type attribute
//
// PUT /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}/{id}
//
// https://docs.go-atlassian.io/jira-assets/object/type/attribute#update-object-type-attribute
Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *models.ObjectTypeAttributeScheme) (
Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *models.ObjectTypeAttributePayloadScheme) (
*models.ObjectTypeAttributeScheme, *models.ResponseScheme, error)

// Delete deletes an existing object type attribute
Expand Down

0 comments on commit 810da40

Please sign in to comment.