Skip to content

Commit

Permalink
Adding openapi code generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzrlk committed Jul 1, 2024
1 parent 9fd6a90 commit daffcea
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 8 deletions.
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
default: testacc
default: build

# Compile module.
build:
#: Generate OpenAPI clients
codegen: internal/idmc/client.gen.go
.PHONY: gen

internal/idmc/client.gen.go: \
tools/oapi-codegen.yml \
internal/idmc/apiv2.yml \
internal/idmc/apiv3.yml
go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen \
--config=${<} \
internal/idmc/*.yml

#: Compile module.
build: \
codegen
go install
.PHONY: build

Expand All @@ -12,5 +25,5 @@ docs:

#: Run acceptance tests.
verify:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
TF_ACC=1 go test ./... -v ${TESTARGS} -timeout 120m
.PHONY: verify
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-testing v1.8.0
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0
)

require (
Expand Down
169 changes: 169 additions & 0 deletions internal/idmc/apiv2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
openapi: '3.0.0'
info:
title: 'Admin API for IDMC'
version: '0.0.0'
paths:
/ma/api/v2/user/login:
post:
operationId: login
requestBody:
content:
application/json:
schema:
type: object
properties:
'@type':
type: string
default: login
username:
type: string
description: |-
Informatica Intelligent Cloud Services user name for the organization that you
want to log in to.
Maximum length is 255 characters.
password:
type: string
description: |-
Informatica Intelligent Cloud Services password.
Maximum length is 255 characters.
required:
- username
- password
responses:
200:
description: |-
Returns the user object if the request is successful.
content:
application/json:
schema:
type: object
properties:
id:
type: string
description: |-
User ID.
orgId:
type: string
description: |-
ID of the organization the user belongs to. 22 characters.
NOTE: Organizations that were created in legacy Informatica Cloud might have an
organization ID of 6 characters.
orgUuid:
type: string
description: |-
Unique identifier for the organization.
name:
type: string
description: |-
Informatica Intelligent Cloud Services user name.
description:
type: string
description: |-
Description of the user.
createTime:
type: string
description: |-
When the user account was created.
updateTime:
type: string
description: |-
When the user account was last updated.
createdBy:
type: string
description: |-
Informatica Intelligent Cloud Services user who created the user account.
updatedBy:
type: string
description: |-
Informatica Intelligent Cloud Services user who last updated the user account.
sfUsername:
type: string
description: |-
Salesforce user name. Included when user is configured to authenticate through Salesforce.
password:
type: string
description: |-
Salesforce user password. Included when user is configured to authenticate through Salesforce.
firstName:
type: string
description: |-
First name for the user account.
lastName:
type: string
description: |-
Last name for the user account.
title:
type: string
description: |-
Title of the user.
phone:
type: string
description: |-
Phone number for the user.
securityQuestion:
type: string
description: |-
Security question. Returns one of the following codes:
SPOUSE_MEETING_CITY
FIRST_JOB_CITY
CHILDHOOD_FRIEND
MOTHER_MAIDEN_NAME
PET_NAME
CHILDHOOD_NICKNAME
CUSTOM_QUESTION:"<question>"
securityAnswer:
type: string
description: |-
Answer to the security question.
roles:
type: object
properties:
name:
type: string
description: |-
Role name. Returns one of the following codes:
Service Consumer
Designer
Admin
description:
type: string
description: |-
Role description.
description: |-
Object that includes a role object for each role assigned to the user.
emails:
type: string
description: |-
Email address to be notified when the user changes the account password.
timezone:
type: string
description: |-
Time zone of the user. Time zone honors Daylight Saving Time.
For more information, see Time zone codes.
serverUrl:
type: string
description: |-
Informatica Intelligent Cloud Services URL for the organization the user belongs
to. Use the serverUrl as a base for most version 2 REST API resource URIs.
spiUrl:
type: string
deprecated: true
description: |-
This field is no longer applicable and has been deprecated.
uuId:
type: string
description: |-
Unique identifier for the user.
icSessionId:
type: string
description: |-
Informatica Intelligent Cloud Services session ID for version 2 REST API session.
Use in most version 2 REST API request headers.
forceChangePassword:
type: boolean
description: |-
Determines if the user must reset the password after the user logs in for the first time. Includes the following values:
True. The user must reset the password.
False. The user is not forced to reset the password.
components: {}
7 changes: 7 additions & 0 deletions internal/idmc/apiv3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
openapi: '3.0.0'
info:
title: 'Admin API for IDMC'
version: '0.0.0'
paths: {}

components: {}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
// ensure the documentation is formatted properly.
//go:generate terraform fmt -recursive ./examples/

//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=tools/oapi-codegen.yml internal/idmc/apiv2.yml

// Run the docs generation tool, check its repository for more information on how it works and how docs
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name scaffolding
Expand Down
6 changes: 6 additions & 0 deletions tools/oapi-codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/deepmap/oapi-codegen/HEAD/configuration-schema.json
package: idmc-api
output: internal/idmc/client.gen.go
generate:
models: true
client: true
5 changes: 1 addition & 4 deletions tools/tools.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

//go:build tools

package tools

import (
// Documentation generation
_ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs"
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
)

0 comments on commit daffcea

Please sign in to comment.