### Install go-atlassian Source: https://github.com/ctreminiom/go-atlassian/blob/main/README.md Use 'go get' to install the most recent version of the go-atlassian library. Requires Go 1.20 or later. ```bash go get github.com/ctreminiom/go-atlassian/v2 ``` -------------------------------- ### Basic Authentication Setup Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to set up basic authentication for API requests. ```Go package main import ( "fmt" "github.com/ctreminiom/go-atlassian" "github.com/ctreminiom/go-atlassian/pkg/config" ) func main() { // Basic Authentication var ( apiToken = "YOUR_API_TOKEN" username = "YOUR_EMAIL" ) auth := config.NewBasicAuth(username, apiToken) // Initialize Jira Client jira, err := go_atlassian.NewJiraService( go_atlassian.WithCloudSubdomain("YOUR_CLOUD_SUBDOMAIN"), go_atlassian.WithAuthentication(auth), ) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Jira client initialized successfully for %s\n", jira.Subdomain()) } ``` -------------------------------- ### JQL Guide Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/search-connector.md A guide to using Jira Query Language (JQL) for constructing search queries, including basic syntax and complex query examples. ```APIDOC ## JQL (Jira Query Language) Guide ### Basic Syntax **Projects:** ```jql project = "Project Key" project in (PROJ1, PROJ2) ``` **Issue Types:** ```jql issuetype = Bug issuetype in (Bug, Feature) issuetype != Epic ``` **Status:** ```jql status = "In Progress" status in ("To Do", "In Progress") status changed after -7d ``` **Users:** ```jql assignee = currentUser() assignee = "user@example.com" assignee in (user1, user2) assignee is EMPTY ``` **Dates:** ```jql created >= -30d created between (2024-01-01, 2024-12-31) updated >= "2024-06-01" ``` **Text Search:** ```jql text ~ "search term" summary ~ "bug" description ~ "urgent" ``` **Labels:** ```jql labels = "documentation" labels in ("bug", "enhancement") labels is EMPTY ``` **Components:** ```jql component = "Backend" component in ("API", "Database") ``` **Priority:** ```jql priority = Highest priority in (High, Highest) ``` **Linked Issues:** ```jql key in linkedIssues("MYPROJ-1", "blocks") issueFunction in issueMatchesAll("priority >= High") ``` ### Complex Queries **AND/OR Operations:** ```jql project = MYPROJ AND status = "In Progress" project = MYPROJ OR project = OTHERPROJ (status = "In Progress" OR status = "In Review") AND priority = High ``` **ORDER BY:** ```jql project = MYPROJ ORDER BY created DESC project = MYPROJ ORDER BY priority DESC, created ASC project = MYPROJ ORDER BY updated DESC ``` **Combining Filters:** ```jql project = MYPROJ AND issuetype = Bug AND status = "Open" AND assignee = currentUser() ORDER BY created DESC ``` **Recurring Events:** ```jql updated >= startOfDay() created >= startOfWeek() updated >= startOfMonth() ``` ``` -------------------------------- ### Jira Assets Management Example Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/COMPLETION_SUMMARY.txt Shows how to interact with Jira Assets (formerly Insight) objects. ```Go package main import ( "fmt" "github.com/ctreminiom/go-atlassian" "github.com/ctreminiom/go-atlassian/pkg/config" ) func main() { // Basic Authentication for Jira Assets API var ( apiToken = "YOUR_API_TOKEN" username = "YOUR_EMAIL" ) auth := config.NewBasicAuth(username, apiToken) // Initialize Jira Assets Client assets, err := go_atlassian.NewAssetsService( go_atlassian.WithCloudSubdomain("YOUR_CLOUD_SUBDOMAIN"), go_atlassian.WithAuthentication(auth), ) if err != nil { fmt.Printf("Error: %v\n", err) return } // Example: Get an object by its ID objectID := "123" object, _, err := assets.Object.Get(objectID) if err != nil { fmt.Printf("Error getting Jira Asset object %s: %v\n", objectID, err) return } fmt.Printf("Object Name: %s\n", object.Name) } ``` -------------------------------- ### Admin Operations Example Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/COMPLETION_SUMMARY.txt Illustrates performing an operation using the Admin Cloud API. ```Go package main import ( "fmt" "github.com/ctreminiom/go-atlassian" "github.com/ctreminiom/go-atlassian/pkg/config" ) func main() { // Basic Authentication for Admin API var ( apiToken = "YOUR_ADMIN_API_TOKEN" username = "YOUR_ADMIN_EMAIL" ) auth := config.NewBasicAuth(username, apiToken) // Initialize Admin Client admin, err := go_atlassian.NewAdminService( go_atlassian.WithCloudSubdomain("YOUR_ADMIN_CLOUD_SUBDOMAIN"), go_atlassian.WithAuthentication(auth), ) if err != nil { fmt.Printf("Error: %v\n", err) return } // Example: Get organization details orgID := "YOUR_ORG_ID" organization, _, err := admin.Organization.Get(orgID) if err != nil { fmt.Printf("Error getting organization %s: %v\n", orgID, err) return } fmt.Printf("Organization Name: %s\n", organization.Name) } ``` -------------------------------- ### Basic Development Configuration Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/configuration.md A simple setup for local development using basic authentication with credentials from environment variables. ```go // Basic setup for local development client, err := v3.New(nil, "https://your-domain.atlassian.net") client.Auth.SetBasicAuth(os.Getenv("JIRA_EMAIL"), os.Getenv("JIRA_TOKEN")) ``` -------------------------------- ### JQL - Combining Filters Example Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/search-connector.md A comprehensive example demonstrating how to combine various JQL filters (project, issuetype, status, assignee) with an ORDER BY clause. ```jql project = MYPROJ AND issuetype = Bug AND status = "Open" AND assignee = currentUser() ORDER BY created DESC ``` -------------------------------- ### Initialize Jira Client with Full URL Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/QUICKSTART.md Ensure you provide a complete Jira URL when initializing the client. This example shows the correct format. ```go // Good v3.New(nil, "https://your-domain.atlassian.net") // Bad v3.New(nil, "your-domain") ``` -------------------------------- ### Get Issue Transitions Source: https://github.com/ctreminiom/go-atlassian/blob/main/README.md Example of how to retrieve issue transitions using the Issue service. This demonstrates fetching an issue and iterating through its transitions. ```APIDOC ## Get Issue Transitions ### Description Retrieves transitions for a given issue. ### Method GET ### Endpoint `/rest/api/3/issue/{issueIdOrKey}` (with `expand=transitions` query parameter) ### Parameters #### Path Parameters - **issueIdOrKey** (string) - Required - The ID or key of the issue. #### Query Parameters - **expand** (array of strings) - Optional - Specifies additional fields to expand, e.g., `transitions`. ### Request Example ```go ctx := context.Background() issueKey := "KP-2" expand := []string{"transitions"} issue, response, err := atlassian.Issue.Get(ctx, issueKey, nil, expand) if err != nil { log.Fatal(err) } log.Println(issue.Key) for _, transition := range issue.Transitions { log.Println(transition.Name, transition.ID, transition.To.ID, transition.HasScreen) } ``` ### Response #### Success Response (200) - **issue** (object) - Contains issue details including transitions. - **response** (object) - The HTTP response object. - **err** (error) - An error object if the request failed. ``` -------------------------------- ### Example ADF Document Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/types.md An example of creating a DocumentScheme object to represent bold text within a paragraph. ```go description := &model.DocumentScheme{ Version: 1, Type: "doc", Content: []*model.DocumentContentScheme{ { Type: "paragraph", Content: []*model.DocumentContentScheme{ {Type: "text", Text: "This is bold text", Marks: []*model.DocumentMarkScheme{ {Type: "strong"}, }}, }, }, }, } ``` -------------------------------- ### Example Update Operations Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/types.md Demonstrates creating an UpdateOperations object to change the summary and status fields of an issue. ```go operations := &model.UpdateOperations{ Operations: []*model.Operation{ {Op: "set", Path: "/fields/summary", Value: "New title"}, {Op: "set", Path: "/fields/status", Value: "In Progress"}, }, } ``` -------------------------------- ### Example: Fetching Paginated Issues Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/types.md Demonstrates how to retrieve the first page of issues and subsequently fetch the next page based on pagination metadata. ```go // Get first 50 issues results, _, err := client.Issue.Search.Get(ctx, jql, options, 0, 50) // Get next page if results.StartAt + results.MaxResults < results.Total { nextResults, _, err := client.Issue.Search.Get( ctx, jql, options, results.StartAt + results.MaxResults, 50, ) } ``` -------------------------------- ### Search for Users Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/README.md Find users based on a username query. This example returns up to 10 users. ```bash client.User.Search(ctx, username, 0, 10) ``` -------------------------------- ### Get Jira Project Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Retrieves details for a specific Jira project by its key. You can specify properties to expand. ```go project, _, _ := client.Project.Get(ctx, "PROJ", expand) ``` -------------------------------- ### Search for Issues Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/README.md Perform a JQL search to find issues. This example retrieves the first 50 issues matching the query. ```bash client.Issue.Search.Get(ctx, jql, nil, 0, 50) ``` -------------------------------- ### Get Project Details Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/README.md Retrieve information about a specific project using its key. The last argument can be used for expand options. ```bash client.Project.Get(ctx, "PROJ", nil) ``` -------------------------------- ### Get a Jira Issue Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/QUICKSTART.md Retrieves details for a specific Jira issue using its key. Requires an initialized client and context. ```go ctx := context.Background() issue, _, err := client.Issue.Get(ctx, "PROJ-123", nil, nil) if err != nil { log.Fatal(err) } fmt.Printf("Issue: %s\n", issue.Key) fmt.Printf("Title: %s\n", issue.Fields.Summary) fmt.Printf("Status: %s\n", issue.Fields.Status.Name) ``` -------------------------------- ### Get Project Issues Helper in Go Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/QUICKSTART.md Retrieves a list of issues for a given project, ordered by creation date. It fetches the latest 100 issues. ```go func getProjectIssues(ctx context.Context, client *v3.Client, projectKey string) ([]*model.IssueScheme, error) { jql := fmt.Sprintf("project = %s ORDER BY created DESC", projectKey) results, _, err := client.Issue.Search.Get(ctx, jql, nil, 0, 100) if err != nil { return nil, err } return results.Issues, nil } ``` -------------------------------- ### Initialize Admin Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Admin client. Note that this client does not require a domain. ```go import "github.com/ctreminiom/go-atlassian/v2/admin" client, err := admin.New(httpClient, options...) ``` -------------------------------- ### JQL - Recurring Events Functions Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/search-connector.md Examples of using built-in JQL functions to filter issues based on recurring time periods like start of day, week, or month. ```jql updated >= startOfDay() created >= startOfWeek() updated >= startOfMonth() ``` -------------------------------- ### Initialize Confluence Client and Perform Operations Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/QUICKSTART.md Demonstrates how to initialize the Confluence client, authenticate, and perform operations like getting, searching, and creating content. Ensure you replace 'your-domain.atlassian.net', 'email@example.com', and 'api-token' with your actual credentials. ```go import "github.com/ctreminiom/go-atlassian/v2/confluence" // Initialize Confluence client client, err := confluence.New(nil, "https://your-domain.atlassian.net") if err != nil { log.Fatal(err) } client.Auth.SetBasicAuth("email@example.com", "api-token") ctx := context.Background() // Get content content, _, err := client.Content.Get(ctx, "12345", []string{"space", "history"}, 0) if err != nil { log.Fatal(err) } fmt.Printf("Page: %s\n", content.Title) // Search pages results, _, err := client.Content.Search( ctx, "type = page AND space = MYSPACE", "", nil, "", 10, ) if err != nil { log.Fatal(err) } fmt.Printf("Found %d pages\n", len(results.Results)) // Create page payload := &model.ContentScheme{ Type: "page", Title: "New Page", Space: &model.SpaceScheme{Key: "MYSPACE"}, Body: &model.BodyScheme{ Storage: &model.StorageScheme{ Value: "

Page content here

", Representation: "storage", }, }, } created, _, err := client.Content.Create(ctx, payload) if err != nil { log.Fatal(err) } fmt.Printf("Created page: %s\n", created.ID) ``` -------------------------------- ### GET /rest/api/3/myself/preferences Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/user-connector.md Gets a user preference value for the current user by specifying the preference key. ```APIDOC ## GET /rest/api/3/myself/preferences ### Description Gets a user preference value for the current user by specifying the preference key. ### Method GET ### Endpoint /rest/api/3/myself/preferences ### Parameters #### Query Parameters - **key** (string) - Required - Preference key name ### Response #### Success Response (200) - **string** - Preference value - **ResponseScheme** (*model.ResponseScheme) - HTTP response metadata ### Request Example ```go value, _, err := client.MySelf.Preferences(ctx, "jira.user.locale") if err != nil { log.Fatal(err) } fmt.Printf("Preference value: %s\n", value) ``` ``` -------------------------------- ### OAuth 2.0 Initialization Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/COMPLETION_SUMMARY.txt Shows how to initialize the client using OAuth 2.0 authentication. ```Go package main import ( "fmt" "github.com/ctreminiom/go-atlassian" "github.com/ctreminiom/go-atlassian/pkg/config" ) func main() { // OAuth 2.0 Authentication var ( clientID = "YOUR_CLIENT_ID" clientSecret = "YOUR_CLIENT_SECRET" refreshToken = "YOUR_REFRESH_TOKEN" scopes = []string{"read:jira-user", "write:jira-work"} ) auth := config.NewOAuth2(clientID, clientSecret, refreshToken, scopes) // Initialize Jira Client jira, err := go_atlassian.NewJiraService( go_atlassian.WithCloudSubdomain("YOUR_CLOUD_SUBDOMAIN"), go_atlassian.WithAuthentication(auth), ) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Jira client initialized successfully for %s\n", jira.Subdomain()) } ``` -------------------------------- ### Example Workflow for Assets Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/assets-client.md Demonstrates a typical workflow for interacting with the Assets Client, including retrieving schemas, object types, attributes, and querying objects. ```go // 1. Get available schemas schemas, _, _ := client.ObjectSchema.Gets(ctx) // 2. Get object types in schema types, _, _ := client.ObjectType.Gets(ctx, schemas[0].ID) // 3. Get attributes for object type attrs, _, _ := client.ObjectTypeAttribute.Gets(ctx, types[0].ID) // 4. Create object with attributes // 5. Query objects with AQL ``` -------------------------------- ### Gets - Retrieve all object schemas Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/assets-client.md Retrieves all object schemas defined in the system. This is useful for getting an overview of available asset types. ```APIDOC ## GET /gateway/api/v1/objectschemas ### Description Retrieves all object schemas. ### Method GET ### Endpoint /gateway/api/v1/objectschemas ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example ```go schemas, _, err := client.ObjectSchema.Gets(ctx) if err != nil { log.Fatal(err) } for _, schema := range schemas { fmt.Printf("Schema: %s (ID: %s) ", schema.Name, schema.ID) } ``` ### Response #### Success Response (200) - **schemas** (*[]*model.AssetsObjectSchemaScheme) - Object schemas ``` -------------------------------- ### Initialize go-atlassian Client with Valid Site URL Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/configuration.md Ensure the site URL provided to v3.New is complete and includes the domain. Trailing slashes are handled automatically. ```go // Good v3.New(nil, "https://your-domain.atlassian.net") // Also good - trailing slash added automatically v3.New(nil, "https://your-domain.atlassian.net/") // Bad - missing domain v3.New(nil, "https://atlassian.net") ``` -------------------------------- ### Gets All Object Types in a Schema Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/assets-client.md Retrieves all object types within a specified schema. This method is useful for getting a comprehensive list of available object types for a given schema. ```APIDOC ## GET /gateway/api/v1/objecttypes ### Description Retrieves all object types in a schema. ### Method GET ### Endpoint GET /gateway/api/v1/objecttypes ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go // Assuming 'client' is an initialized Assets client types, _, err := client.ObjectType.Gets(ctx, "schema-123") if err != nil { log.Fatal(err) } for _, ot := range types { fmt.Printf("Type: %s (ID: %d)\n", ot.Name, ot.ID) } ``` ### Response #### Success Response (200) - **[]*model.AssetsObjectTypeScheme** - Object types - ***model.ResponseScheme** - HTTP response metadata #### Response Example ```json [ { "id": 1, "name": "User", "description": "Represents a user in the system" }, { "id": 2, "name": "Device", "description": "Represents a hardware device" } ] ``` ``` -------------------------------- ### Initialize Jira v3 Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Jira v3 client. Ensure you have the correct httpClient, domain, and any necessary options. ```go import "github.com/ctreminiom/go-atlassian/v2/jira/v3" client, err := v3.New(httpClient, "https://domain.atlassian.net", options...) ``` -------------------------------- ### GET /rest/api/3/myself/locale Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/user-connector.md Retrieves the locale/language preference of the current user. ```APIDOC ## GET /rest/api/3/myself/locale ### Description Retrieves the locale/language preference of the current user. ### Method GET ### Endpoint /rest/api/3/myself/locale ### Response #### Success Response (200) - **UserLocaleScheme** (*model.UserLocaleScheme) - Locale information - **ResponseScheme** (*model.ResponseScheme) - HTTP response metadata #### Response Example { "example": "{\"locale\": \"en_US\"}" } ### Request Example ```go locale, _, err := client.MySelf.Locale(ctx) if err != nil { log.Fatal(err) } fmt.Printf("Locale: %s\n", locale.Locale) ``` ``` -------------------------------- ### Initialize Jira v2 Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Jira v2 client. Ensure you have the correct httpClient, domain, and any necessary options. ```go import "github.com/ctreminiom/go-atlassian/v2/jira/v2" client, err := v2.New(httpClient, "https://domain.atlassian.net", options...) ``` -------------------------------- ### Get Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/assets-client.md Retrieves a specific asset object by its ID from Jira Assets. ```APIDOC ## GET /gateway/api/v1/objects/{objectId} ### Description Retrieves a specific asset object by ID. ### Method GET ### Endpoint /gateway/api/v1/objects/{objectId} ### Parameters #### Path Parameters - **objectID** (string) - Yes - Object ID ### Response #### Success Response (200) - **AssetsObjectDataScheme** (*model.AssetsObjectDataScheme) - Object details - **ResponseScheme** (*model.ResponseScheme) - HTTP response metadata ``` -------------------------------- ### Initialize Confluence Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Confluence client. Ensure you have the correct httpClient, domain, and any necessary options. ```go import "github.com/ctreminiom/go-atlassian/v2/confluence" client, err := confluence.New(httpClient, "https://domain.atlassian.net", options...) ``` -------------------------------- ### Get Project Statuses Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/project-connector.md Retrieves valid statuses for a project, grouped by issue type. ```APIDOC ## GET /rest/api/3/project/{projectKeyOrID}/statuses ### Description Retrieves valid statuses for a project, grouped by issue type. ### Method GET ### Endpoint /rest/api/3/project/{projectKeyOrID}/statuses ### Parameters #### Path Parameters - **projectKeyOrID** (string) - Required - Project key or ID #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **Statuses grouped by issue type** ([]*model.ProjectStatusPageScheme) - Statuses grouped by issue type - **HTTP response metadata** (*model.ResponseScheme) - HTTP response metadata #### Response Example ```go statuses, _, err := client.Project.Statuses(ctx, "MYPROJ") if err != nil { log.Fatal(err) } for _, page := range statuses { fmt.Printf("Issue Type: %s\n", page.Name) for _, status := range page.Statuses { fmt.Printf(" - %s\n", status.Name) } } ``` ``` -------------------------------- ### Get Organization Users Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves all users within a specified organization. Supports pagination. ```APIDOC ## Users ### Description Retrieves all users within a specified organization. Supports pagination. ### Method GET ### Endpoint /admin/v1/orgs/{organizationID}/users ### Parameters #### Path Parameters - **organizationID** (string) - Required - Organization ID #### Query Parameters - **cursor** (string) - Optional - Pagination cursor #### Request Body (None) ### Response #### Success Response (200) - **Data** (*model.OrganizationUserPageScheme) - Paginated users - **Response** (*model.ResponseScheme) - HTTP response metadata ### Example ```go users, _, err := client.Organization.Users(ctx, "org-id-12345", "") if err != nil { log.Fatal(err) } for _, user := range users.Data { fmt.Printf("User: %s (%s)\\n", user.Email, user.AccountID) } ``` ``` -------------------------------- ### Initialize Agile Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Agile client for Jira. Ensure you have the correct httpClient, domain, and any necessary options. ```go import "github.com/ctreminiom/go-atlassian/v2/jira/agile" client, err := agile.New(httpClient, "https://domain.atlassian.net", options...) ``` -------------------------------- ### Correct and Incorrect Site Provisioning Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Demonstrates the correct way to initialize the Jira Cloud v3 client by providing the full Atlassian site URL. Incorrect initialization omits the scheme, leading to errors. ```go // Correct v3.New(nil, "https://domain.atlassian.net") // Incorrect v3.New(nil, "domain.atlassian.net") ``` -------------------------------- ### Get Organization by ID Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves detailed information for a specific organization using its ID. ```APIDOC ## Get ### Description Retrieves detailed information for a specific organization using its ID. ### Method GET ### Endpoint /admin/v1/orgs/{organizationID} ### Parameters #### Path Parameters - **organizationID** (string) - Required - Organization ID #### Query Parameters (None) #### Request Body (None) ### Response #### Success Response (200) - **Organization** (*model.AdminOrganizationScheme) - Organization details - **Response** (*model.ResponseScheme) - HTTP response metadata ### Example ```go org, _, err := client.Organization.Get(ctx, "org-id-12345") if err != nil { log.Fatal(err) } fmt.Printf("Organization: %s\\n", org.Name) ``` ``` -------------------------------- ### Initialize Client with Default HTTP Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/configuration.md Initializes the client using Go's default http.Client. This is suitable for basic configurations without specific transport requirements. ```go // Uses http.DefaultClient client, err := v3.New(nil, "https://your-domain.atlassian.net") ``` -------------------------------- ### Get Organization Domains Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves all verified domains associated with an organization. Pagination is supported. ```go domains, _, err := client.Organization.Domains(ctx, "org-id-12345", "") if err != nil { log.Fatal(err) } for _, domain := range domains.Data { fmt.Printf("Domain: %s\n", domain.Domain) } ``` -------------------------------- ### Get Organization Users Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves all users within a specified organization. Supports pagination. ```go users, _, err := client.Organization.Users(ctx, "org-id-12345", "") if err != nil { log.Fatal(err) } for _, user := range users.Data { fmt.Printf("User: %s (%s)\n", user.Email, user.AccountID) } ``` -------------------------------- ### AQL Query Examples Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/assets-client.md Illustrates various AQL query syntaxes for filtering objects, including basic queries, multiple conditions, attribute comparisons, and relationship traversals. ```aql // Basic queries object type = "Server" Name = "prod-server-1" // Multiple conditions object type = "Server" AND Status = "Active" object type in ("Server", "Switch") OR Status = "Retired" // Attribute comparisons CPUCores >= 8 Environment = "Production" // Relationships related to "PROJ-123" ``` -------------------------------- ### Get Organization Domains Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves all verified domains associated with a specific organization. Supports pagination. ```APIDOC ## Domains ### Description Retrieves all verified domains associated with a specific organization. Supports pagination. ### Method GET ### Endpoint /admin/v1/orgs/{organizationID}/domains ### Parameters #### Path Parameters - **organizationID** (string) - Required - Organization ID #### Query Parameters - **cursor** (string) - Optional - Pagination cursor #### Request Body (None) ### Response #### Success Response (200) - **Data** (*model.OrganizationDomainPageScheme) - Paginated domains - **Response** (*model.ResponseScheme) - HTTP response metadata ### Example ```go domains, _, err := client.Organization.Domains(ctx, "org-id-12345", "") if err != nil { log.Fatal(err) } for _, domain := range domains.Data { fmt.Printf("Domain: %s\\n", domain.Domain) } ``` ``` -------------------------------- ### Initialize Jira Client with OAuth2 Configuration Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/authentication-connector.md Sets up a new Jira client using OAuth 2.0 configuration. Ensure your OAuth app is registered and the correct credentials are provided. ```go oauthConfig := &common.OAuth2Config{ ClientID: "your-client-id", ClientSecret: "your-client-secret", RedirectURI: "https://your-app.com/oauth/callback", } client, err := jira.New( http.DefaultClient, "https://api.atlassian.com", jira.WithOAuth(oauthConfig), ) ``` -------------------------------- ### Get Organizations Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves all organizations accessible to the authenticated user. Supports pagination via a cursor. ```APIDOC ## Gets ### Description Retrieves all organizations accessible to the authenticated user. Supports pagination via a cursor. ### Method GET ### Endpoint /admin/v1/orgs ### Parameters #### Path Parameters (None) #### Query Parameters - **cursor** (string) - Optional - Pagination cursor for next page #### Request Body (None) ### Response #### Success Response (200) - **Data** (*model.AdminOrganizationPageScheme) - Paginated organizations - **Response** (*model.ResponseScheme) - HTTP response metadata ### Example ```go orgs, _, err := client.Organization.Gets(ctx, "") if err != nil { log.Fatal(err) } for _, org := range orgs.Data { fmt.Printf("Organization: %s (%s)\\n", org.Name, org.ID) } ``` ``` -------------------------------- ### Load Jira Credentials from Environment Variables Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/configuration.md Loads Jira URL, email, and token from environment variables. Initializes a v3 client and sets basic authentication. ```go import "os" jiraURL := os.Getenv("JIRA_URL") if jiraURL == "" { log.Fatal("JIRA_URL not set") } email := os.Getenv("JIRA_EMAIL") if email == "" { log.Fatal("JIRA_EMAIL not set") } token := os.Getenv("JIRA_TOKEN") if token == "" { log.Fatal("JIRA_TOKEN not set") } client, err := v3.New(nil, jiraURL) if err != nil { log.Fatal(err) } if err := client.Auth.SetBasicAuth(email, token); err != nil { log.Fatal(err) } ``` -------------------------------- ### Get All Organizations Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves all organizations accessible to the authenticated user. Supports pagination via a cursor. ```go orgs, _, err := client.Organization.Gets(ctx, "") if err != nil { log.Fatal(err) } for _, org := range orgs.Data { fmt.Printf("Organization: %s (%s)\n", org.Name, org.ID) } ``` -------------------------------- ### Initialize Assets Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Assets client. The domain for Assets API is typically 'https://api.atlassian.com'. ```go import "github.com/ctreminiom/go-atlassian/v2/assets" client, err := assets.New(httpClient, "https://api.atlassian.com", options...) ``` -------------------------------- ### Initialize OAuth Authentication Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/README.md Initialize a new client with OAuth configuration. Ensure the OAuth config is properly set up before use. ```bash client, _ := v3.New(nil, url, v3.WithOAuth(config)) ``` -------------------------------- ### Initialize Client with Custom HTTP Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/configuration.md Configure a custom http.Client for advanced control over timeouts, TLS settings, proxies, and other transport behaviors. This allows fine-tuning network requests. ```go import ( "net" "net/http" "time" ) transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 5 * time.Second, KeepAlive: 30 * time.Second, }).Dial, TLSHandshakeTimeout: 10 * time.Second, MaxIdleConns: 100, MaxIdleConnsPerHost: 10, } httpClient := &http.Client{ Transport: transport, Timeout: 30 * time.Second, } client, err := v3.New(httpClient, "https://your-domain.atlassian.net") if err != nil { log.Fatal(err) } ``` -------------------------------- ### Gets Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/assets-client.md Retrieves a paginated list of asset objects from Jira Assets. Supports filtering and pagination options. ```APIDOC ## GET /gateway/api/v1/objects/{schemaId} ### Description Retrieves paginated list of asset objects. ### Method GET ### Endpoint /gateway/api/v1/objects/{schemaId} ### Parameters #### Path Parameters - **schemaID** (string) - Yes - Object schema ID #### Query Parameters - **startAt** (int) - No - Pagination start index - **maxResults** (int) - No - Results per page (default 50) #### Request Body - **options** (*model.AssetsObjectsOptionsScheme) - No - Filter options (objectType, filter, etc.) ### Response #### Success Response (200) - **AssetsObjectScheme** (*model.AssetsObjectScheme) - Paginated assets - **ResponseScheme** (*model.ResponseScheme) - HTTP response metadata ``` -------------------------------- ### Initialize Jira Client with Basic Auth Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/jira-client.md Creates a new Jira API client instance using basic authentication. Pass nil for the HTTP client to use the default. The site URL is required, and functional options can be provided for further configuration. ```go import ( "log" "github.com/ctreminiom/go-atlassian/v2/jira/v3" ) client, err := v3.New(nil, "https://your-domain.atlassian.net") if err != nil { log.Fatal(err) } client.Auth.SetBasicAuth("your-email@example.com", "your-api-token") ``` -------------------------------- ### Get Workflow Scheme by ID Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/workflow-connector.md Retrieves details for a specific workflow scheme using its unique ID. ```APIDOC ## GET /rest/api/3/workflowscheme/{schemeID} ### Description Retrieves details for a specific workflow scheme using its unique ID. ### Method GET ### Endpoint /rest/api/3/workflowscheme/{schemeID} ### Parameters #### Path Parameters - **schemeID** (int) - Yes - Workflow scheme ID ### Response #### Success Response (200) - **Name** (string) - Name of the workflow scheme - **IssueTypeMapping** (object) - Mapping of issue types to workflows ### Request Example ```go scheme, _, err := client.Workflow.Schemes.Get(ctx, 12345) if err != nil { log.Fatal(err) } fmt.Printf("Scheme: %s\n", scheme.Name) for issueType, workflow := range scheme.IssueTypeMapping { fmt.Printf(" %s -> %s\n", issueType, workflow) } ``` ``` -------------------------------- ### Example Jira Workflow Pattern Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/workflow-connector.md This Go code illustrates a common pattern for managing Jira workflows. It covers creating a workflow, setting up a workflow scheme, assigning the scheme to a project, and then utilizing it for issue transitions. ```go // 1. Create a workflow with transitions // 2. Create a workflow scheme // 3. Assign scheme to project // 4. Use in issue transitions ``` -------------------------------- ### Initialize Admin Cloud Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Creates a new Admin Cloud API client. Use `nil` for the HTTP client to use the default. Authentication can be set using `SetBasicAuth`. ```go import ( "log" "github.com/ctreminiom/go-atlassian/v2/admin" ) client, err := admin.New(nil) if err != nil { log.Fatal(err) } client.Auth.SetBasicAuth("user@example.com", "api-token") ``` -------------------------------- ### Get Confluence Content Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Retrieves specific Confluence content by its ID. Allows specifying fields to expand and the version. ```go content, _, _ := client.Content.Get(ctx, contentID, expand, version) ``` -------------------------------- ### Get Specific Jira User Details Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Retrieves details for a specific Jira user using their account ID. ```go user, _, _ := client.User.Get(ctx, accountID) ``` -------------------------------- ### Configure and Authorize OAuth 2.0 Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/README.md Set up an OAuth 2.0 configuration with your client ID and secret. Use this to create a client for the authorization flow and generate the authorization URL. After user authorization, exchange the authorization code for tokens. ```go // Configure OAuth oauthConfig := &common.OAuth2Config{ ClientID: "YOUR_CLIENT_ID", ClientSecret: "YOUR_CLIENT_SECRET", RedirectURI: "https://your-app.com/callback", } // Create client with OAuth support for the authorization flow client, err := jira.New( http.DefaultClient, "https://api.atlassian.com", // Temporary URL for OAuth flow jira.WithOAuth(oauthConfig), ) if err != nil { log.Fatal(err) } // Generate authorization URL scopes := []string{"read:jira-work", "write:jira-work"} authURL, err := client.OAuth.GetAuthorizationURL(scopes, "state") if err != nil { log.Fatal(err) } // Direct user to authURL to authorize your app fmt.Printf("Visit this URL to authorize: %s\n", authURL.String()) // After authorization, exchange code for tokens ctx := context.Background() token, err := client.OAuth.ExchangeAuthorizationCode(ctx, "AUTH_CODE") if err != nil { log.Fatal(err) } // Option 1: Manual token management client.Auth.SetBearerToken(token.AccessToken) // Option 2: Create new client with auto-renewal (recommended) client, err = jira.New( http.DefaultClient, "https://your-domain.atlassian.net", jira.WithOAuth(oauthConfig), // OAuth service jira.WithAutoRenewalToken(token), // Auto-renewal ) if err != nil { log.Fatal(err) } // Make API calls myself, _, err := client.MySelf.Details(ctx, nil) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Initialize Service Management Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/INDEX.md Use this to create a new Service Management client for Jira. Ensure you have the correct httpClient, domain, and any necessary options. ```go import "github.com/ctreminiom/go-atlassian/v2/jira/sm" client, err := sm.New(httpClient, "https://domain.atlassian.net", options...) ``` -------------------------------- ### Gets Workflow Schemes Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/workflow-connector.md Retrieves all workflow schemes with pagination. Allows filtering by name and setting pagination parameters. ```APIDOC ## GET /rest/api/3/workflowscheme ### Description Retrieves all workflow schemes with pagination. Allows filtering by name and setting pagination parameters. ### Method GET ### Endpoint /rest/api/3/workflowscheme ### Parameters #### Query Parameters - **startAt** (int) - Optional - Pagination start index - **maxResults** (int) - Optional - Results per page (default 50) - **name** (string) - Optional - Filter by workflow scheme name ### Response #### Success Response (200) - **Values** (array) - Paginated workflow schemes ### Request Example ```go schemes, _, err := client.Workflow.Schemes.Gets(ctx, 0, 10, "") if err != nil { log.Fatal(err) } for _, scheme := range schemes.Values { fmt.Printf("Scheme: %s\n", scheme.Name) } ``` ``` -------------------------------- ### Get Workflow Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/workflow-connector.md Retrieves details for a specific workflow by its name. Supports expanding fields like transitions and statuses. ```APIDOC ## GET /rest/api/3/workflows/{workflowName} ### Description Retrieves details for a specific workflow by name. ### Method GET ### Endpoint /rest/api/3/workflows/{workflowName} ### Parameters #### Path Parameters - **workflowName** (`string`) - Required - Name of the workflow #### Query Parameters - **expand** (`[]string`) - Optional - Fields to expand (transitions, statuses) ### Request Example ```json { "workflowName": "Default", "expand": ["transitions"] } ``` ### Response #### Success Response (200) - **id** (`string`) - The workflow ID - **name** (`string`) - The workflow name - **description** (`string`) - The workflow description - **transitions** (`[]model.WorkflowTransitionScheme`) - List of workflow transitions #### Response Example ```json { "id": "123", "name": "Default", "description": "Default Jira workflow", "transitions": [ { "id": "1", "name": "Start Progress", "from": ["Open"], "to": "In Progress" } ] } ``` ``` -------------------------------- ### Project Directory Structure Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/README.md This snippet shows the organizational structure of the Go-Atlassian project's documentation files. ```bash ``` /output/ ├── README.md # This file ├── INDEX.md # Master index (START HERE) ├── QUICKSTART.md # Quick start guide ├── configuration.md # Authentication & setup ├── types.md # Type definitions └── api-reference/ ├── jira-client.md ├── issue-connector.md ├── project-connector.md ├── search-connector.md ├── user-connector.md ├── workflow-connector.md ├── confluence-client.md ├── admin-client.md ├── assets-client.md └── authentication-connector.md ``` ``` -------------------------------- ### GET /rest/api/3/myself Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/user-connector.md Retrieves details for the currently authenticated user. Supports expanding fields like groups and applicationRoles. ```APIDOC ## GET /rest/api/3/myself ### Description Retrieves details for the currently authenticated user. Supports expanding fields like groups and applicationRoles. ### Method GET ### Endpoint /rest/api/3/myself ### Parameters #### Query Parameters - **expand** ([]string) - Optional - Fields to expand (groups, applicationRoles) ### Request Example ```go myself, _, err := client.MySelf.Details(ctx, []string{"groups", "applicationRoles"}) if err != nil { log.Fatal(err) } fmt.Printf("Logged in as: %s (%s)\\n", myself.DisplayName, myself.Email) fmt.Printf("Account ID: %s\\n", myself.AccountID) fmt.Printf("Active: %v\\n", myself.Active) ``` ### Response #### Success Response (200) - **UserScheme** (*model.UserScheme) - Current user details - **ResponseScheme** (*model.ResponseScheme) - HTTP response metadata #### Response Example { "example": "{\"displayName\": \"John Doe\", \"email\": \"john.doe@example.com\", \"accountId\": \"12345\", \"active\": true}" } ``` -------------------------------- ### Initialize Jira Client Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/QUICKSTART.md Initializes a new Jira client and sets basic authentication using email and API token. This client can then be used to make API calls. ```go package main import ( "context" "log" "github.com/ctreminiom/go-atlassian/v2/jira/v3" ) func main() { // Create client client, err := v3.New(nil, "https://your-domain.atlassian.net") if err != nil { log.Fatal(err) } // Set authentication if err := client.Auth.SetBasicAuth("your-email@example.com", "your-api-token"); err != nil { log.Fatal(err) } // Now you can make API calls ctx := context.Background() myself, _, err := client.MySelf.Details(ctx, nil) if err != nil { log.Fatal(err) } log.Printf("Logged in as: %s\n", myself.DisplayName) } ``` -------------------------------- ### Initialize Admin Client with OAuth Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/configuration.md Initializes an Admin client with OAuth 2.0 authentication and automatic token renewal. This setup is suitable for administrative tasks requiring authenticated API access. ```go import "github.com/ctreminiom/go-atlassian/v2/admin" // Assuming oauthConfig and token are already defined client, err := admin.New( http.DefaultClient, admin.WithOAuth(oauthConfig), admin.WithAutoRenewalToken(token), ) ``` -------------------------------- ### Get Content History Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/confluence-client.md Retrieves the edit history of a piece of content. You can specify fields to expand in the history details. ```APIDOC ## GET /wiki/rest/api/content/{id}/history ### Description Retrieves the edit history of a piece of content. You can specify fields to expand in the history details. ### Method GET ### Endpoint /wiki/rest/api/content/{id}/history ### Parameters #### Path Parameters - **id** (string) - Yes - Content ID #### Query Parameters - **expand** ([]string) - No - Fields to expand in history ### Request Example ```go history, _, err := client.Content.History(ctx, "12345", nil) if err != nil { log.Fatal(err) } fmt.Printf("Last modified: %s\n", history.LastUpdated.When) fmt.Printf("Created: %s\n", history.CreatedDate) ``` ### Response #### Success Response (200) - **history** (*model.ContentHistoryScheme) - Content history - **response** (*model.ResponseScheme) - HTTP response metadata ``` -------------------------------- ### Get Specific Organization Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/api-reference/admin-client.md Retrieves details for a specific organization using its ID. Ensure the organization ID is correct. ```go org, _, err := client.Organization.Get(ctx, "org-id-12345") if err != nil { log.Fatal(err) } fmt.Printf("Organization: %s\n", org.Name) ``` -------------------------------- ### User Search Patterns Source: https://github.com/ctreminiom/go-atlassian/blob/main/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to search for users within Jira. ```Go package main import ( "fmt" "github.com/ctreminiom/go-atlassian" "github.com/ctreminiom/go-atlassian/pkg/config" ) func main() { // Basic Authentication var ( apiToken = "YOUR_API_TOKEN" username = "YOUR_EMAIL" ) auth := config.NewBasicAuth(username, apiToken) // Initialize Jira Client jira, err := go_atlassian.NewJiraService( go_atlassian.WithCloudSubdomain("YOUR_CLOUD_SUBDOMAIN"), go_atlassian.WithAuthentication(auth), ) if err != nil { fmt.Printf("Error: %v\n", err) return } query := "john.doe@example.com" users, _, err := jira.User.Search(query, 0, 10) if err != nil { fmt.Printf("Error searching users: %v\n", err) return } fmt.Printf("Found %d users:\n", len(users)) for _, user := range users { fmt.Printf("- %s (%s)\n", user.DisplayName, user.EmailAddress) } } ```